From d30fb9e72ca9c3e38728694439f2af6a61407431 Mon Sep 17 00:00:00 2001 From: Eratosthenes Date: Wed, 23 Feb 2011 11:59:59 -0500 Subject: [PATCH] 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)