From 65a0c367810eacd0eb01393c920766f6640160e1 Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Sat, 13 Feb 2010 17:26:47 +0000 Subject: [PATCH] use original config instance, improve hero_id handling (think this fixes auto-import empty db problem?) --- pyfpdb/HUD_main.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/pyfpdb/HUD_main.py b/pyfpdb/HUD_main.py index e26fd611..2ea223f4 100755 --- a/pyfpdb/HUD_main.py +++ b/pyfpdb/HUD_main.py @@ -72,7 +72,7 @@ class HUD_main(object): def __init__(self, db_name = 'fpdb'): print "\nHUD_main: starting ..." self.db_name = db_name - self.config = Configuration.Config(file=options.config, dbname = db_name) + self.config = c print "Logfile is " + os.path.join(self.config.dir_log, 'HUD-log.txt') log.info("HUD_main starting: using db name = %s" % (db_name)) @@ -207,12 +207,7 @@ class HUD_main(object): # get hero's screen names and player ids self.hero, self.hero_ids = {}, {} - for site in self.config.get_supported_sites(): - result = self.db_connection.get_site_id(site) - if result: - site_id = result[0][0] - self.hero[site_id] = self.config.supported_sites[site].screen_name - self.hero_ids[site_id] = self.db_connection.get_player_id(self.config, site, self.hero[site_id]) + found = False while 1: # wait for a new hand number on stdin new_hand_id = sys.stdin.readline() @@ -224,6 +219,18 @@ class HUD_main(object): self.destroy() break # this thread is not always killed immediately with gtk.main_quit() + if not found: + for site in self.config.get_supported_sites(): + result = self.db_connection.get_site_id(site) + if result: + site_id = result[0][0] + self.hero[site_id] = self.config.supported_sites[site].screen_name + self.hero_ids[site_id] = self.db_connection.get_player_id(self.config, site, self.hero[site_id]) + if self.hero_ids[site_id] is not None: + found = True + else: + self.hero_ids[site_id] = -1 + # get basic info about the new hand from the db # if there is a db error, complain, skip hand, and proceed log.info("HUD_main.read_stdin: hand processing starting ...")