Merge branch 'master' of git://git.assembla.com/fpdb-sql

This commit is contained in:
Eratosthenes 2009-12-04 12:16:17 -05:00
commit 193944799d
2 changed files with 21 additions and 1 deletions

View File

@ -196,7 +196,10 @@ class GuiGraphViewer (threading.Thread):
self.ax.plot(green, color='green', label='Hands: %d\nProfit: $%.2f' %(len(green), green[-1]))
self.ax.plot(blue, color='blue', label='Showdown: $%.2f' %(blue[-1]))
self.ax.plot(red, color='red', label='Non-showdown: $%.2f' %(red[-1]))
self.ax.legend(loc='best', fancybox=True, shadow=True, prop=FontProperties(size='smaller'))
if sys.version[0:3] == '2.5':
self.ax.legend(loc='best', shadow=True, prop=FontProperties(size='smaller'))
else:
self.ax.legend(loc='best', fancybox=True, shadow=True, prop=FontProperties(size='smaller'))
self.graphBox.add(self.canvas)

View File

@ -68,6 +68,9 @@ elif os.name == 'nt':
import Hud
log = Configuration.get_logger("logging.conf")
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.
@ -199,6 +202,8 @@ class HUD_main(object):
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
new_hand_id = string.rstrip(new_hand_id)
self.log.debug("Received hand no %s" % new_hand_id)
if new_hand_id == "": # blank line means quit
@ -213,6 +218,7 @@ class HUD_main(object):
except Exception, err:
self.log.error("db error: skipping %s" % new_hand_id)
continue
t1 = time.time()
if type == "tour": # hand is from a tournament
temp_key = tour_number
@ -222,6 +228,12 @@ class HUD_main(object):
# Update an existing HUD
if temp_key in self.hud_dict:
# get stats using hud's specific params and get cards
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)
t3 = time.time()
try:
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'])
@ -245,8 +257,10 @@ 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'] )
t4 = time.time()
stat_dict = self.db_connection.get_stats_from_hand(new_hand_id, type, self.hud_params
,self.hero_ids[site_id], num_seats)
t5 = time.time()
cards = self.db_connection.get_cards(new_hand_id)
comm_cards = self.db_connection.get_common_cards(new_hand_id)
if comm_cards != {}: # stud!
@ -271,6 +285,9 @@ class HUD_main(object):
else:
sys.stderr.write('Table "%s" no longer exists\n' % table_name)
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))
self.db_connection.connection.rollback()
if __name__== "__main__":