Catch match error on new tables retry or fail gracefully.

This commit is contained in:
Eratosthenes 2011-02-23 11:59:59 -05:00
parent 4744fe3b90
commit d30fb9e72c
2 changed files with 11 additions and 3 deletions

View File

@ -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

View File

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