use original config instance, improve hero_id handling (think this fixes auto-import empty db problem?)

This commit is contained in:
sqlcoder 2010-02-13 17:26:47 +00:00
parent 906c9e0bc9
commit 65a0c36781

View File

@ -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 ...")