diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py old mode 100755 new mode 100644 diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index 6006a246..d634e134 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -32,16 +32,12 @@ import sys import Configuration import SQL -try: # pgdb database module for posgres via DB-API - import psycopg2 -except: - pass +import psycopg2 +# pgdb uses pyformat. is that fixed or an option? + # mysql bindings -try: - import MySQLdb -except: - pass +import MySQLdb class Database: def __init__(self, c, db_name, game): diff --git a/pyfpdb/HUD_config.xml.example b/pyfpdb/HUD_config.xml.example index 649493fa..423787c5 100644 --- a/pyfpdb/HUD_config.xml.example +++ b/pyfpdb/HUD_config.xml.example @@ -2,7 +2,7 @@ - + @@ -22,16 +22,16 @@ - - - + + + - - + + @@ -44,87 +44,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + diff --git a/pyfpdb/HUD_main.py b/pyfpdb/HUD_main.py index 15bbd034..a839c2a1 100755 --- a/pyfpdb/HUD_main.py +++ b/pyfpdb/HUD_main.py @@ -38,6 +38,9 @@ import os import thread import Queue +errorfile = open('HUD-error.txt', 'w') +sys.stderr = errorfile + # pyGTK modules import pygtk import gtk @@ -105,13 +108,13 @@ def producer(): # This is the thread function dataQueue.put(hand_no) # and puts result on the queue if __name__== "__main__": - print "HUD_main starting" + sys.stderr.write("HUD_main starting\n") try: db_name = sys.argv[1] except: db_name = 'fpdb-p' - print "Using db name = ", db_name + sys.stderr.write("Using db name = %s\n" % (db_name)) config = Configuration.Config() # db_connection = Database.Database(config, 'fpdb', 'holdem') diff --git a/pyfpdb/Tables.py b/pyfpdb/Tables.py index 41db0645..cb6209c8 100644 --- a/pyfpdb/Tables.py +++ b/pyfpdb/Tables.py @@ -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) diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py index dbbc746f..98f0aa27 100755 --- a/pyfpdb/fpdb.py +++ b/pyfpdb/fpdb.py @@ -18,8 +18,8 @@ import os import sys -#errorfile = open('fpdb-error.log', 'w') -#sys.stderr = errorfile +errorfile = open('fpdb-error.log', 'w') +sys.stderr = errorfile import pygtk pygtk.require('2.0')