From 461c870690f6ebb411f8b8cd82185e74f270bf89 Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 11 Nov 2008 14:25:56 -0500 Subject: [PATCH] Fine tuning tournament support. --- pyfpdb/HUD_main.py | 4 ---- pyfpdb/Tables.py | 8 +++++--- 2 files changed, 5 insertions(+), 7 deletions(-) mode change 100644 => 100755 pyfpdb/Tables.py diff --git a/pyfpdb/HUD_main.py b/pyfpdb/HUD_main.py index e869fac6..1a7e058e 100755 --- a/pyfpdb/HUD_main.py +++ b/pyfpdb/HUD_main.py @@ -93,7 +93,6 @@ def read_stdin(): # This is the thread function db_connection = Database.Database(config, db_name, 'temp') tourny_finder = re.compile('(\d+) (\d+)') - print tourny_finder while True: # wait for a new hand number on stdin new_hand_id = sys.stdin.readline() @@ -115,10 +114,8 @@ def read_stdin(): # This is the thread function mat_obj = tourny_finder.search(table_name) # if len(mat_obj.groups) == 2: if mat_obj: - print "found tournament", is_tournament = True (tour_number, tab_number) = mat_obj.group(1, 2) - print " number = %s, table = %s" % (tour_number, tab_number) stat_dict = db_connection.get_stats_from_hand(new_hand_id) @@ -132,7 +129,6 @@ def read_stdin(): # This is the thread function else: if is_tournament: tablewindow = Tables.discover_tournament_table(config, tour_number, tab_number) - print tablewindow if tablewindow == None: sys.stderr.write("tournament %s, table %s not found\n" % (tour_number, tab_number)) else: diff --git a/pyfpdb/Tables.py b/pyfpdb/Tables.py old mode 100644 new mode 100755 index 2db1ca92..2b312f40 --- a/pyfpdb/Tables.py +++ b/pyfpdb/Tables.py @@ -223,6 +223,7 @@ def discover_nt(c): def discover_nt_by_name(c, tablename): """Finds poker client window with the given table name.""" + titles = {} win32gui.EnumWindows(win_enum_handler, titles) for hwnd in titles.keys(): if titles[hwnd].find(tablename) == -1: continue @@ -233,7 +234,7 @@ def discover_nt_by_name(c, tablename): def discover_nt_tournament(c, tour_number, tab_number): """Finds the Windows window handle for the given tournament/table.""" - search_string = "%s.+%s" % (t_number, s_number) + search_string = "%s.+%s" % (tour_number, tab_number) titles ={} win32gui.EnumWindows(win_enum_handler, titles) @@ -260,12 +261,13 @@ def decode_windows(c, title, hwnd): info = {} info['number'] = hwnd info['title'] = re.sub('\"', '', title) - (x, y, w, h) = win32gui.GetWindowRect(hwnd) + (x, y, width, height) = win32gui.GetWindowRect(hwnd) info['x'] = int(x) + b_width info['y'] = int( y ) + tb_height info['width'] = int( width ) - 2*b_width info['height'] = int( height ) - b_width - tb_height + info['exe'] = get_nt_exe(hwnd) title_bits = re.split(' - ', info['title']) info['name'] = title_bits[0] @@ -427,7 +429,7 @@ if __name__=="__main__": c = Configuration.Config() print discover_table_by_name(c, "Ostara V") - print discover_tournament_table(c, "119736621", "1") + print discover_tournament_table(c, "118942908", "3") tables = discover(c) for t in tables.keys():