p107 - HUD updates from ray, FTP now supported

This commit is contained in:
steffen123
2008-09-26 14:18:47 +01:00
parent ce3187667c
commit b549aa2605
6 changed files with 135 additions and 100 deletions
+32 -12
View File
@@ -42,7 +42,7 @@ class Table_Window:
# __str__ method for testing
temp = 'TableWindow object\n'
temp = temp + " name = %s\n site = %s\n number = %s\n title = %s\n" % (self.name, self.site, self.number, self.title)
temp = temp + " game = %s\n structure = %s\n max = %s\n" % (self.game, self.structure, self.max)
# temp = temp + " game = %s\n structure = %s\n max = %s\n" % (self.game, self.structure, self.max)
temp = temp + " width = %d\n height = %d\n x = %d\n y = %d\n" % (self.width, self.height, self.x, self.y)
if getattr(self, 'tournament', 0):
temp = temp + " tournament = %d\n table = %d" % (self.tournament, self.table)
@@ -73,9 +73,10 @@ def discover_posix(c):
tables = {}
for listing in os.popen('xwininfo -root -tree').readlines():
# xwininfo -root -tree -id 0xnnnnn gets the info on a single window
if re.search('Lobby', listing): continue
if re.search('Instant Hand History', listing): continue
if not re.search('Logged In as ', listing): continue
if re.search('Lobby', listing): continue
if re.search('Instant Hand History', listing): continue
if not re.search('Logged In as ', listing, re.IGNORECASE): continue
if re.search('\"Full Tilt Poker\"', listing): continue # FTP Lobby
for s in c.supported_sites.keys():
if re.search(c.supported_sites[s].table_finder, listing):
mo = re.match('\s+([\dxabcdef]+) (.+):.+ (\d+)x(\d+)\+\d+\+\d+ \+(\d+)\+(\d+)', listing)
@@ -90,8 +91,6 @@ def discover_posix(c):
tw.x = int (mo.group(5) )
tw.y = int (mo.group(6) )
tw.title = re.sub('\"', '', tw.title)
# this rather ugly hack makes my fake table used for debugging work
if tw.title == "PokerStars.py": continue
# use this eval thingie to call the title bar decoder specified in the config file
eval("%s(tw)" % c.supported_sites[s].decoder)
@@ -138,9 +137,10 @@ def discover_nt(c):
tables = {}
win32gui.EnumWindows(win_enum_handler, titles)
for hwnd in titles.keys():
if re.search('Logged In as', titles[hwnd]) and not re.search('Lobby', titles[hwnd]):
if re.search('Logged In as', titles[hwnd], re.IGNORECASE) and not re.search('Lobby', titles[hwnd]):
if re.search('Full Tilt Poker', titles[hwnd]):
continue
tw = Table_Window()
# tw.site = c.supported_sites[s].site_name
tw.number = hwnd
(x, y, width, height) = win32gui.GetWindowRect(hwnd)
tw.title = titles[hwnd]
@@ -148,10 +148,17 @@ def discover_nt(c):
tw.height = int( height ) - b_width - tb_height
tw.x = int( x ) + b_width
tw.y = int( y ) + tb_height
eval("%s(tw)" % "pokerstars_decode_table")
tw.site = "PokerStars"
if re.search('Logged In as', titles[hwnd]):
tw.site = "PokerStars"
elif re.search('Logged In As', titles[hwnd]):
tw.site = "Full Tilt"
else:
tw.site = "Unknown"
sys.stderr.write("Found unknown table = %s" % tw.title)
if not tw.site == "Unknown":
eval("%s(tw)" % c.supported_sites[tw.site].decoder)
else:
tw.name = "Unknown"
tables[tw.name] = tw
return tables
@@ -199,6 +206,19 @@ def pokerstars_decode_table(tw):
elif tw.game in ('omaha', 'omaha hi/lo'):
pass
def fulltilt_decode_table(tw):
# extract the table name OR the tournament number and table name from the title
# other info in title is redundant with data in the database
title_bits = re.split(' - ', tw.title)
name = title_bits[0]
tw.tournament = None
for pattern in [r' \(6 max\)', r' \(heads up\)', r' \(deep\)',
r' \(deep hu\)', r' \(deep 6\)', r' \(2\)',
r' \(edu\)', r' \(edu, 6 max\)', r' \(6\)' ]:
name = re.sub(pattern, '', name)
# (tw.name, trash) = name.split(r' (', 1)
tw.name = name.rstrip()
if __name__=="__main__":
c = Configuration.Config()
tables = discover(c)