From a1783a37cbd0b399a87f3049c62340e91de62a57 Mon Sep 17 00:00:00 2001 From: Eric Blade Date: Tue, 15 Sep 2009 21:04:00 -0500 Subject: [PATCH] reflow init_hud_stat_vars exception handling --- pyfpdb/Database.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index 011da193..32437d5f 100755 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -370,23 +370,20 @@ class Database: def init_hud_stat_vars(self, hud_days): """Initialise variables used by Hud to fetch stats.""" + self.hand_1day_ago = 1 try: - # self.hand_1day_ago used to fetch stats for current session (i.e. if hud_style = 'S') - self.hand_1day_ago = 1 c = self.get_cursor() c.execute(self.sql.query['get_hand_1day_ago']) row = c.fetchone() + except: # TODO: what error is a database error?! + err = traceback.extract_tb(sys.exc_info()[2])[-1] + print "*** Error: " + err[2] + "(" + str(err[1]) + "): " + str(sys.exc_info()[1]) + else: if row and row[0]: - self.hand_1day_ago = row[0] - #print "hand 1day ago =", self.hand_1day_ago - - # self.date_ndays_ago used if hud_style = 'T' + self.hand_1_day_ago = row[0] d = timedelta(days=hud_days) now = datetime.utcnow() - d - self.date_ndays_ago = "d%02d%02d%02d" % (now.year-2000, now.month, now.day) - except: - err = traceback.extract_tb(sys.exc_info()[2])[-1] - print "***Error: "+err[2]+"("+str(err[1])+"): "+str(sys.exc_info()[1]) + self.date_ndays_ago = "d%02d%02d%02d" % (now.year - 2000, now.month, now.day) def init_player_hud_stat_vars(self, playerid): # not sure if this is workable, to be continued ...