slight formatting changes to agree with PEP8 moar closely
This commit is contained in:
parent
4b3fe3dfa2
commit
bfec231b5d
|
@ -61,17 +61,19 @@ elif os.name == 'nt':
|
|||
import Hud
|
||||
|
||||
import locale
|
||||
lang=locale.getdefaultlocale()[0][0:2]
|
||||
lang = locale.getdefaultlocale()[0][0:2]
|
||||
print "lang:", lang
|
||||
if lang=="en":
|
||||
def _(string): return string
|
||||
if lang == "en":
|
||||
def _(string):
|
||||
return string
|
||||
else:
|
||||
import gettext
|
||||
try:
|
||||
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
|
||||
trans.install()
|
||||
except IOError:
|
||||
def _(string): return string
|
||||
def _(string):
|
||||
return string
|
||||
|
||||
# get config and set up logger
|
||||
c = Configuration.Config(file=options.config, dbname=options.dbname)
|
||||
|
@ -82,7 +84,7 @@ class HUD_main(object):
|
|||
"""A main() object to own both the read_stdin thread and the gui."""
|
||||
# This class mainly provides state for controlling the multiple HUDs.
|
||||
|
||||
def __init__(self, db_name = 'fpdb'):
|
||||
def __init__(self, db_name='fpdb'):
|
||||
print _("\nHUD_main: starting ...")
|
||||
self.db_name = db_name
|
||||
self.config = c
|
||||
|
@ -92,9 +94,9 @@ class HUD_main(object):
|
|||
try:
|
||||
if not options.errorsToConsole:
|
||||
fileName = os.path.join(self.config.dir_log, 'HUD-errors.txt')
|
||||
print _("Note: error output is being diverted to:\n")+fileName \
|
||||
print _("Note: error output is being diverted to:\n") + fileName \
|
||||
+ _("\nAny major error will be reported there _only_.\n")
|
||||
log.info(_("Note: error output is being diverted to:")+fileName)
|
||||
log.info(_("Note: error output is being diverted to:") + fileName)
|
||||
log.info(_("Any major error will be reported there _only_."))
|
||||
errorFile = open(fileName, 'w', 0)
|
||||
sys.stderr = errorFile
|
||||
|
@ -104,8 +106,8 @@ class HUD_main(object):
|
|||
self.hud_params = self.config.get_hud_ui_parameters()
|
||||
|
||||
# a thread to read stdin
|
||||
gobject.threads_init() # this is required
|
||||
thread.start_new_thread(self.read_stdin, ()) # starts the thread
|
||||
gobject.threads_init() # this is required
|
||||
thread.start_new_thread(self.read_stdin, ()) # starts the thread
|
||||
|
||||
# a main window
|
||||
self.main_window = gtk.Window()
|
||||
|
@ -123,7 +125,7 @@ class HUD_main(object):
|
|||
self.main_window.show_all()
|
||||
gobject.timeout_add(100, self.check_tables)
|
||||
except:
|
||||
log.error( "*** Exception in HUD_main.init() *** " )
|
||||
log.error("*** Exception in HUD_main.init() *** ")
|
||||
for e in traceback.format_tb(sys.exc_info()[2]):
|
||||
log.error(e)
|
||||
|
||||
|
@ -135,7 +137,7 @@ class HUD_main(object):
|
|||
print "hud_main: Client resized"
|
||||
print hud, hud.table.name, hud.table.x, hud.table.y
|
||||
|
||||
def client_destroyed(self, widget, hud): # call back for terminating the main eventloop
|
||||
def client_destroyed(self, widget, hud): # call back for terminating the main eventloop
|
||||
print "hud_main: client destroyed"
|
||||
self.kill_hud(None, hud.table.name)
|
||||
|
||||
|
@ -157,7 +159,7 @@ class HUD_main(object):
|
|||
self.hud_dict[table].main_window.destroy()
|
||||
self.vb.remove(self.hud_dict[table].tablehudlabel)
|
||||
del(self.hud_dict[table])
|
||||
self.main_window.resize(1,1)
|
||||
self.main_window.resize(1, 1)
|
||||
|
||||
def check_tables(self):
|
||||
for hud in self.hud_dict.keys():
|
||||
|
@ -185,7 +187,7 @@ class HUD_main(object):
|
|||
self.hud_dict[table_name].update(new_hand_id, self.config)
|
||||
self.hud_dict[table_name].reposition_windows()
|
||||
except:
|
||||
log.error( "*** Exception in HUD_main::idle_func() *** " + str(sys.exc_info()) )
|
||||
log.error("*** Exception in HUD_main::idle_func() *** " + str(sys.exc_info()))
|
||||
for e in traceback.format_tb(sys.exc_info()[2]):
|
||||
log.error(e)
|
||||
finally:
|
||||
|
@ -251,7 +253,7 @@ class HUD_main(object):
|
|||
self.hero, self.hero_ids = {}, {}
|
||||
found = False
|
||||
|
||||
while 1: # wait for a new hand number on stdin
|
||||
while 1: # wait for a new hand number on stdin
|
||||
new_hand_id = sys.stdin.readline()
|
||||
t0 = time.time()
|
||||
t1 = t2 = t3 = t4 = t5 = t6 = t0
|
||||
|
@ -295,8 +297,8 @@ class HUD_main(object):
|
|||
self.db_connection.init_hud_stat_vars( self.hud_dict[temp_key].hud_params['hud_days']
|
||||
, self.hud_dict[temp_key].hud_params['h_hud_days'])
|
||||
t2 = time.time()
|
||||
stat_dict = self.db_connection.get_stats_from_hand(new_hand_id, type, self.hud_dict[temp_key].hud_params
|
||||
,self.hero_ids[site_id], num_seats)
|
||||
stat_dict = self.db_connection.get_stats_from_hand(new_hand_id, type, self.hud_dict[temp_key].hud_params,
|
||||
self.hero_ids[site_id], num_seats)
|
||||
t3 = time.time()
|
||||
|
||||
try:
|
||||
|
@ -307,7 +309,7 @@ class HUD_main(object):
|
|||
# Unlocks table, copied from end of function
|
||||
self.db_connection.connection.rollback()
|
||||
return
|
||||
cards = self.db_connection.get_cards(new_hand_id)
|
||||
cards = self.db_connection.get_cards(new_hand_id)
|
||||
t4 = time.time()
|
||||
comm_cards = self.db_connection.get_common_cards(new_hand_id)
|
||||
t5 = time.time()
|
||||
|
@ -321,14 +323,14 @@ class HUD_main(object):
|
|||
else:
|
||||
# get stats using default params--also get cards
|
||||
self.db_connection.init_hud_stat_vars( self.hud_params['hud_days'], self.hud_params['h_hud_days'] )
|
||||
stat_dict = self.db_connection.get_stats_from_hand(new_hand_id, type, self.hud_params
|
||||
,self.hero_ids[site_id], num_seats)
|
||||
stat_dict = self.db_connection.get_stats_from_hand(new_hand_id, type, self.hud_params,
|
||||
self.hero_ids[site_id], num_seats)
|
||||
cards = self.db_connection.get_cards(new_hand_id)
|
||||
comm_cards = self.db_connection.get_common_cards(new_hand_id)
|
||||
if comm_cards != {}: # stud!
|
||||
cards['common'] = comm_cards['common']
|
||||
|
||||
table_kwargs = dict(table_name = table_name, tournament = tour_number, table_number = tab_number)
|
||||
table_kwargs = dict(table_name=table_name, tournament=tour_number, table_number=tab_number)
|
||||
tablewindow = Tables.Table(self.config, site_name, **table_kwargs)
|
||||
if tablewindow is None:
|
||||
# If no client window is found on the screen, complain and continue
|
||||
|
@ -346,7 +348,7 @@ class HUD_main(object):
|
|||
|
||||
t6 = time.time()
|
||||
log.info(_("HUD_main.read_stdin: hand read in %4.3f seconds (%4.3f,%4.3f,%4.3f,%4.3f,%4.3f,%4.3f)")
|
||||
% (t6-t0,t1-t0,t2-t0,t3-t0,t4-t0,t5-t0,t6-t0))
|
||||
% (t6 - t0,t1 - t0,t2 - t0,t3 - t0,t4 - t0,t5 - t0,t6 - t0))
|
||||
self.db_connection.connection.rollback()
|
||||
if type == "tour":
|
||||
tablewindow.check_table_no()
|
||||
|
|
|
@ -53,6 +53,7 @@ import Mucked
|
|||
import Database
|
||||
#import HUD_main
|
||||
|
||||
|
||||
def importName(module_name, name):
|
||||
"""Import a named object 'name' from module 'module_name'."""
|
||||
# Recipe 16.3 in the Python Cookbook, 2nd ed. Thanks!!!!
|
||||
|
@ -63,12 +64,12 @@ def importName(module_name, name):
|
|||
return None
|
||||
return(getattr(module, name))
|
||||
|
||||
class Hud:
|
||||
|
||||
class Hud:
|
||||
def __init__(self, parent, table, max, poker_game, config, db_connection):
|
||||
# __init__ is (now) intended to be called from the stdin thread, so it
|
||||
# cannot touch the gui
|
||||
if parent is None: # running from cli ..
|
||||
if parent is None: # running from cli ..
|
||||
self.parent = self
|
||||
else:
|
||||
self.parent = parent
|
||||
|
@ -83,7 +84,6 @@ class Hud:
|
|||
self.mw_created = False
|
||||
self.hud_params = parent.hud_params
|
||||
|
||||
|
||||
self.stat_windows = {}
|
||||
self.popup_windows = {}
|
||||
self.aux_windows = []
|
||||
|
@ -115,11 +115,11 @@ class Hud:
|
|||
def create_mw(self):
|
||||
# Set up a main window for this this instance of the HUD
|
||||
win = gtk.Window()
|
||||
win.set_skip_taskbar_hint(True) # invisible to taskbar
|
||||
win.set_skip_taskbar_hint(True) # invisible to taskbar
|
||||
win.set_gravity(gtk.gdk.GRAVITY_STATIC)
|
||||
win.set_title("%s FPDBHUD" % (self.table.name)) # give it a title that we can easily filter out in the window list when Table search code is looking
|
||||
win.set_decorated(False) # kill titlebars
|
||||
win.set_opacity(self.colors["hudopacity"]) # set it to configured hud opacity
|
||||
win.set_decorated(False) # kill titlebars
|
||||
win.set_opacity(self.colors["hudopacity"]) # set it to configured hud opacity
|
||||
win.set_focus(None)
|
||||
win.set_focus_on_map(False)
|
||||
win.set_accept_focus(False)
|
||||
|
@ -165,9 +165,9 @@ class Hud:
|
|||
# set agg_bb_mult to 1 to stop aggregation
|
||||
item = gtk.CheckMenuItem(_('For This Blind Level Only'))
|
||||
self.aggMenu.append(item)
|
||||
item.connect("activate", self.set_aggregation, ('P',1))
|
||||
item.connect("activate", self.set_aggregation, ('P', 1))
|
||||
setattr(self, 'h_aggBBmultItem1', item)
|
||||
|
||||
|
||||
item = gtk.MenuItem(_('For Multiple Blind Levels:'))
|
||||
self.aggMenu.append(item)
|
||||
|
||||
|
@ -362,7 +362,7 @@ class Hud:
|
|||
item.ms = i
|
||||
maxSeatsMenu.append(item)
|
||||
item.connect("activate", self.change_max_seats)
|
||||
setattr(self, 'maxSeatsMenuItem%d' % (i-1), item)
|
||||
setattr(self, 'maxSeatsMenuItem%d' % (i - 1), item)
|
||||
|
||||
eventbox.connect_object("button-press-event", self.on_button_press, menu)
|
||||
|
||||
|
@ -544,7 +544,7 @@ class Hud:
|
|||
loc = self.stat_windows[sw].window.get_position()
|
||||
new_loc = (loc[0] - self.table.x, loc[1] - self.table.y)
|
||||
new_layout[self.stat_windows[sw].adj - 1] = new_loc
|
||||
self.config.edit_layout(self.table.site, self.max, locations = new_layout)
|
||||
self.config.edit_layout(self.table.site, self.max, locations=new_layout)
|
||||
# ask each aux to save its layout back to the config object
|
||||
[aux.save_layout() for aux in self.aux_windows]
|
||||
# save the config object back to the file
|
||||
|
@ -557,7 +557,7 @@ class Hud:
|
|||
adj = range(0, self.max + 1) # default seat adjustments = no adjustment
|
||||
# does the user have a fav_seat?
|
||||
if self.max not in config.supported_sites[self.table.site].layout:
|
||||
sys.stderr.write(_("No layout found for %d-max games for site %s\n") % (self.max, self.table.site) )
|
||||
sys.stderr.write(_("No layout found for %d-max games for site %s\n") % (self.max, self.table.site))
|
||||
return adj
|
||||
if self.table.site != None and int(config.supported_sites[self.table.site].layout[self.max].fav_seat) > 0:
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue
Block a user