From 3cf03719fdd486f5a5143dd20231e04496488563 Mon Sep 17 00:00:00 2001 From: Eratosthenes Date: Tue, 22 Feb 2011 17:22:44 -0500 Subject: [PATCH 1/5] Extend timeout for dragging...help with slower PCs. --- pyfpdb/HUD_main.pyw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/HUD_main.pyw b/pyfpdb/HUD_main.pyw index 721644bb..04476dae 100755 --- a/pyfpdb/HUD_main.pyw +++ b/pyfpdb/HUD_main.pyw @@ -116,7 +116,7 @@ class HUD_main(object): self.main_window.set_icon_stock(gtk.STOCK_HOME) if not options.hidden: self.main_window.show_all() - gobject.timeout_add(100, self.check_tables) + gobject.timeout_add(800, self.check_tables) except: log.exception("Error initializing main_window") From 991cd088fd54238743ce5a919bad3ddaba6b747a Mon Sep 17 00:00:00 2001 From: Eratosthenes Date: Tue, 22 Feb 2011 17:24:14 -0500 Subject: [PATCH 2/5] Add some logging for XTables.py. --- pyfpdb/XTables.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pyfpdb/XTables.py b/pyfpdb/XTables.py index 703d9d39..7cf9b26e 100644 --- a/pyfpdb/XTables.py +++ b/pyfpdb/XTables.py @@ -40,6 +40,9 @@ from TableWindow import Table_Window disp = Xlib.display.Display() root = disp.screen().root +c = Configuration.Config(file=options.config, dbname=options.dbname) +log = Configuration.get_logger("logging.conf", "hud", log_dir=c.dir_log, log_file='HUD-log.txt') + class Table(Table_Window): def find_table_parameters(self): @@ -61,6 +64,8 @@ class Table(Table_Window): if self.check_bad_words(title): continue self.number = int( mo.groupdict()["XID"], 0 ) self.title = title + if self.number is None: + log.error("Could not retrieve XID from table xwininfo. xwininfo is %s" % listing) break if self.number is None: From 626fbf3986ab2a90db66e6347c555e5ac1bc858b Mon Sep 17 00:00:00 2001 From: Eratosthenes Date: Tue, 22 Feb 2011 18:58:37 -0500 Subject: [PATCH 3/5] More logging in XTables.py. --- pyfpdb/XTables.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pyfpdb/XTables.py b/pyfpdb/XTables.py index 7cf9b26e..19cd5278 100644 --- a/pyfpdb/XTables.py +++ b/pyfpdb/XTables.py @@ -35,12 +35,13 @@ import Xlib.display # FPDB modules from TableWindow import Table_Window +import Configuration # We might as well do this once and make them globals disp = Xlib.display.Display() root = disp.screen().root -c = Configuration.Config(file=options.config, dbname=options.dbname) +c = Configuration.Config() log = Configuration.get_logger("logging.conf", "hud", log_dir=c.dir_log, log_file='HUD-log.txt') class Table(Table_Window): @@ -59,6 +60,7 @@ class Table(Table_Window): self.number = None for listing in os.popen('xwininfo -root -tree').readlines(): if re.search(self.search_string, listing, re.I): + log.info(listing) mo = re.match(reg, listing, re.VERBOSE) title = re.sub('\"', '', mo.groupdict()["TITLE"]) if self.check_bad_words(title): continue From 540b7369c4e47a840a17ffb5bde635f74847e7f8 Mon Sep 17 00:00:00 2001 From: Eratosthenes Date: Tue, 22 Feb 2011 19:05:48 -0500 Subject: [PATCH 4/5] More logging in XTables. --- pyfpdb/XTables.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyfpdb/XTables.py b/pyfpdb/XTables.py index 19cd5278..6ca77e67 100644 --- a/pyfpdb/XTables.py +++ b/pyfpdb/XTables.py @@ -71,6 +71,7 @@ class Table(Table_Window): break if self.number is None: + log.error("No match in XTables for table '%s'." % self.search_string) return None (self.window, self.parent) = self.get_window_from_xid(self.number) From d30fb9e72ca9c3e38728694439f2af6a61407431 Mon Sep 17 00:00:00 2001 From: Eratosthenes Date: Wed, 23 Feb 2011 11:59:59 -0500 Subject: [PATCH 5/5] Catch match error on new tables retry or fail gracefully. --- pyfpdb/TableWindow.py | 10 +++++++++- pyfpdb/XTables.py | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pyfpdb/TableWindow.py b/pyfpdb/TableWindow.py index 05c6ce4e..4cab43ad 100644 --- a/pyfpdb/TableWindow.py +++ b/pyfpdb/TableWindow.py @@ -118,6 +118,7 @@ class Table_Window(object): self.site = site self.hud = None # fill in later self.gdkhandle = None + self.number = None if tournament is not None and table_number is not None: self.tournament = int(tournament) self.table = int(table_number) @@ -135,7 +136,14 @@ class Table_Window(object): return None self.search_string = getTableTitleRe(self.config, self.site, self.type, **table_kwargs) - self.find_table_parameters() + trys = 0 + while True: + self.find_table_parameters() + if self.number is not None: break + trys += 1 + if trys > 4: + log.error("Can't find table %s" % table_name) + return None geo = self.get_geometry() if geo is None: return None diff --git a/pyfpdb/XTables.py b/pyfpdb/XTables.py index 6ca77e67..fa39e044 100644 --- a/pyfpdb/XTables.py +++ b/pyfpdb/XTables.py @@ -67,11 +67,11 @@ class Table(Table_Window): self.number = int( mo.groupdict()["XID"], 0 ) self.title = title if self.number is None: - log.error("Could not retrieve XID from table xwininfo. xwininfo is %s" % listing) + log.warning("Could not retrieve XID from table xwininfo. xwininfo is %s" % listing) break if self.number is None: - log.error("No match in XTables for table '%s'." % self.search_string) + log.warning("No match in XTables for table '%s'." % self.search_string) return None (self.window, self.parent) = self.get_window_from_xid(self.number)