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

0
pyfpdb/Configuration.py Executable file → Normal file
View File

View File

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

View File

@ -2,7 +2,7 @@
<FreePokerToolsConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FreePokerToolsConfig.xsd">
<supported_sites>
<site site_name="PokerStars" table_finder="PokerStars" screen_name="DO NOT NEED THIS YET" site_path="DO NOT NEED THIS YET" HH_path="DO NOT NEED THIS YET" decoder="pokerstars_decode_table">
<site site_name="PokerStars" table_finder="PokerStars" screen_name="DO NOT NEED THIS YET" site_path="~/.wine/drive_c/Program Files/PokerStars/" HH_path="~/.wine/drive_c/Program Files/PokerStars/HandHistory/abc/" decoder="pokerstars_decode_table">
<layout max="8" width="792" height="546" fav_seat="0">
<location seat="1" x="684" y="61"> </location>
<location seat="2" x="689" y="239"> </location>
@ -22,16 +22,16 @@
<location seat="6" x="0" y="119"> </location>
</layout>
<layout max="10" width="792" height="546" fav_seat="0">
<location seat="1" x="560" y="0" > </location>
<location seat="2" x="685" y="113"> </location>
<location seat="3" x="682" y="279"> </location>
<location seat="1" x="684" y="61"> </location>
<location seat="2" x="689" y="239"> </location>
<location seat="3" x="692" y="346"> </location>
<location seat="4" x="586" y="393"> </location>
<location seat="5" x="421" y="440"> </location>
<location seat="6" x="267" y="440"> </location>
<location seat="7" x="0" y="361"> </location>
<location seat="8" x="0" y="280"> </location>
<location seat="9" x="0" y="119"> </location>
<location seat="10" x="139" y="0"> </location>
<location seat="9" x="121" y="280"> </location>
<location seat="10" x="46" y="30"> </location>
</layout>
<layout max="9" width="792" height="546" fav_seat="0">
<location seat="1" x="560" y="0"> </location>
@ -44,87 +44,103 @@
<location seat="8" x="0" y="121"> </location>
<location seat="9" x="140" y="0"> </location>
</layout>
<layout fav_seat="0" height="546" max="2" width="792">
<location seat="1" x="651" y="288"> </location>
<location seat="2" x="10" y="288"> </location>
</layout>
</site>
<site screen_name="PokerMonk" site_name="Full Tilt" table_finder="FullTiltPoker.exe" decoder="fulltilt_decode_table">
<layout fav_seat="0" height="547" max="8" width="794">
<location seat="1" x="640" y="64"> </location>
<location seat="2" x="650" y="230"> </location>
<location seat="3" x="650" y="385"> </location>
<location seat="4" x="588" y="425"> </location>
<location seat="5" x="92" y="425"> </location>
<location seat="6" x="0" y="373"> </location>
<location seat="7" x="0" y="223"> </location>
<location seat="8" x="25" y="50"> </location>
</layout>
<layout fav_seat="0" height="547" max="6" width="794">
<location seat="1" x="640" y="58"> </location>
<location seat="2" x="654" y="288"> </location>
<location seat="3" x="615" y="424"> </location>
<location seat="4" x="70" y="421"> </location>
<location seat="5" x="0" y="280"> </location>
<location seat="6" x="70" y="58"> </location>
</layout>
<layout fav_seat="0" height="547" max="2" width="794">
<location seat="1" x="651" y="288"> </location>
<location seat="2" x="10" y="288"> </location>
</layout>
<layout fav_seat="0" height="547" max="9" width="794">
<location seat="1" x="634" y="38"> </location>
<location seat="2" x="667" y="184"> </location>
<location seat="3" x="667" y="321"> </location>
<location seat="4" x="667" y="445"> </location>
<location seat="5" x="337" y="459"> </location>
<location seat="6" x="0" y="400"> </location>
<location seat="7" x="0" y="322"> </location>
<location seat="8" x="0" y="181"> </location>
<location seat="9" x="70" y="53"> </location>
</layout>
</site>
</supported_sites>
<supported_games>
<game game_name="holdem" db="fpdb" rows="2" cols="3">
<stat row="0" col="0" stat_name="vpip" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="0" col="1" stat_name="pfr" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="0" col="2" stat_name="ffreq_1" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="1" col="0" stat_name="n" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="1" col="1" stat_name="wtsd" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="1" col="2" stat_name="wmsd" tip="tip1" click="tog_decorate" popup="default"> </stat>
<game cols="3" db="fpdb" game_name="holdem" rows="2">
<stat click="tog_decorate" col="0" popup="default" row="0" stat_name="vpip" tip="tip1"> </stat>
<stat click="tog_decorate" col="1" popup="default" row="0" stat_name="pfr" tip="tip1"> </stat>
<stat click="tog_decorate" col="2" popup="default" row="0" stat_name="ffreq_1" tip="tip1"> </stat>
<stat click="tog_decorate" col="0" popup="default" row="1" stat_name="n" tip="tip1"> </stat>
<stat click="tog_decorate" col="1" popup="default" row="1" stat_name="wtsd" tip="tip1"> </stat>
<stat click="tog_decorate" col="2" popup="default" row="1" stat_name="wmsd" tip="tip1"> </stat>
</game>
<game game_name="razz" db="fpdb" rows="2" cols="3">
<stat row="0" col="0" stat_name="vpip" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="0" col="1" stat_name="pfr" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="0" col="2" stat_name="ffreq_1" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="1" col="0" stat_name="n" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="1" col="1" stat_name="wtsd" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="1" col="2" stat_name="wmsd" tip="tip1" click="tog_decorate" popup="default"> </stat>
<game cols="3" db="fpdb" game_name="razz" rows="2">
<stat click="tog_decorate" col="0" popup="default" row="0" stat_name="vpip" tip="tip1"> </stat>
<stat click="tog_decorate" col="1" popup="default" row="0" stat_name="pfr" tip="tip1"> </stat>
<stat click="tog_decorate" col="2" popup="default" row="0" stat_name="ffreq_1" tip="tip1"> </stat>
<stat click="tog_decorate" col="0" popup="default" row="1" stat_name="n" tip="tip1"> </stat>
<stat click="tog_decorate" col="1" popup="default" row="1" stat_name="wtsd" tip="tip1"> </stat>
<stat click="tog_decorate" col="2" popup="default" row="1" stat_name="wmsd" tip="tip1"> </stat>
</game>
<game game_name="omahahi" db="fpdb" rows="2" cols="3">
<stat row="0" col="0" stat_name="vpip" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="0" col="1" stat_name="pfr" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="0" col="2" stat_name="ffreq_1" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="1" col="0" stat_name="n" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="1" col="1" stat_name="wtsd" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="1" col="2" stat_name="wmsd" tip="tip1" click="tog_decorate" popup="default"> </stat>
<game cols="3" db="fpdb" game_name="omahahi" rows="2">
<stat click="tog_decorate" col="0" popup="default" row="0" stat_name="vpip" tip="tip1"> </stat>
<stat click="tog_decorate" col="1" popup="default" row="0" stat_name="pfr" tip="tip1"> </stat>
<stat click="tog_decorate" col="2" popup="default" row="0" stat_name="ffreq_1" tip="tip1"> </stat>
<stat click="tog_decorate" col="0" popup="default" row="1" stat_name="n" tip="tip1"> </stat>
<stat click="tog_decorate" col="1" popup="default" row="1" stat_name="wtsd" tip="tip1"> </stat>
<stat click="tog_decorate" col="2" popup="default" row="1" stat_name="wmsd" tip="tip1"> </stat>
</game>
<game game_name="omahahilo" db="fpdb" rows="2" cols="3">
<stat row="0" col="0" stat_name="vpip" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="0" col="1" stat_name="pfr" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="0" col="2" stat_name="ffreq_1" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="1" col="0" stat_name="n" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="1" col="1" stat_name="wtsd" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="1" col="2" stat_name="wmsd" tip="tip1" click="tog_decorate" popup="default"> </stat>
<game cols="3" db="fpdb" game_name="omahahilo" rows="2">
<stat click="tog_decorate" col="0" popup="default" row="0" stat_name="vpip" tip="tip1"> </stat>
<stat click="tog_decorate" col="1" popup="default" row="0" stat_name="pfr" tip="tip1"> </stat>
<stat click="tog_decorate" col="2" popup="default" row="0" stat_name="ffreq_1" tip="tip1"> </stat>
<stat click="tog_decorate" col="0" popup="default" row="1" stat_name="n" tip="tip1"> </stat>
<stat click="tog_decorate" col="1" popup="default" row="1" stat_name="wtsd" tip="tip1"> </stat>
<stat click="tog_decorate" col="2" popup="default" row="1" stat_name="wmsd" tip="tip1"> </stat>
</game>
<game game_name="studhi" db="fpdb" rows="2" cols="3">
<stat row="0" col="0" stat_name="vpip" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="0" col="1" stat_name="pfr" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="0" col="2" stat_name="ffreq_1" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="1" col="0" stat_name="n" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="1" col="1" stat_name="wtsd" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="1" col="2" stat_name="wmsd" tip="tip1" click="tog_decorate" popup="default"> </stat>
<game cols="3" db="fpdb" game_name="studhi" rows="2">
<stat click="tog_decorate" col="0" popup="default" row="0" stat_name="vpip" tip="tip1"> </stat>
<stat click="tog_decorate" col="1" popup="default" row="0" stat_name="pfr" tip="tip1"> </stat>
<stat click="tog_decorate" col="2" popup="default" row="0" stat_name="ffreq_1" tip="tip1"> </stat>
<stat click="tog_decorate" col="0" popup="default" row="1" stat_name="n" tip="tip1"> </stat>
<stat click="tog_decorate" col="1" popup="default" row="1" stat_name="wtsd" tip="tip1"> </stat>
<stat click="tog_decorate" col="2" popup="default" row="1" stat_name="wmsd" tip="tip1"> </stat>
</game>
<game game_name="studhilo" db="fpdb" rows="2" cols="3">
<stat row="0" col="0" stat_name="vpip" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="0" col="1" stat_name="pfr" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="0" col="2" stat_name="ffreq_1" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="1" col="0" stat_name="n" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="1" col="1" stat_name="wtsd" tip="tip1" click="tog_decorate" popup="default"> </stat>
<stat row="1" col="2" stat_name="wmsd" tip="tip1" click="tog_decorate" popup="default"> </stat>
<game cols="3" db="fpdb" game_name="studhilo" rows="2">
<stat click="tog_decorate" col="0" popup="default" row="0" stat_name="vpip" tip="tip1"> </stat>
<stat click="tog_decorate" col="1" popup="default" row="0" stat_name="pfr" tip="tip1"> </stat>
<stat click="tog_decorate" col="2" popup="default" row="0" stat_name="ffreq_1" tip="tip1"> </stat>
<stat click="tog_decorate" col="0" popup="default" row="1" stat_name="n" tip="tip1"> </stat>
<stat click="tog_decorate" col="1" popup="default" row="1" stat_name="wtsd" tip="tip1"> </stat>
<stat click="tog_decorate" col="2" popup="default" row="1" stat_name="wmsd" tip="tip1"> </stat>
</game>
</supported_games>
<popup_windows>
<pu pu_name="default">
<pu_stat pu_stat_name = "n"> </pu_stat>
<pu_stat pu_stat_name = "vpip"> </pu_stat>
<pu_stat pu_stat_name = "pfr"> </pu_stat>
<pu_stat pu_stat_name = "three_B_0"> </pu_stat>
<pu_stat pu_stat_name = "steal"> </pu_stat>
<pu_stat pu_stat_name = "f_BB_steal"> </pu_stat>
<pu_stat pu_stat_name = "f_SB_steal"> </pu_stat>
<pu_stat pu_stat_name = "wmsd"> </pu_stat>
<pu_stat pu_stat_name = "wtsd"> </pu_stat>
<pu_stat pu_stat_name = "WMsF"> </pu_stat>
<pu_stat pu_stat_name = "a_freq_1"> </pu_stat>
<pu_stat pu_stat_name = "a_freq_2"> </pu_stat>
<pu_stat pu_stat_name = "a_freq_3"> </pu_stat>
<pu_stat pu_stat_name = "a_freq_4"> </pu_stat>
<pu_stat pu_stat_name = "cb_1"> </pu_stat>
<pu_stat pu_stat_name = "cb_2"> </pu_stat>
<pu_stat pu_stat_name = "cb_3"> </pu_stat>
<pu_stat pu_stat_name = "cb_4"> </pu_stat>
<pu_stat pu_stat_name = "ffreq_1"> </pu_stat>
<pu_stat pu_stat_name = "ffreq_2"> </pu_stat>
<pu_stat pu_stat_name = "ffreq_3"> </pu_stat>
<pu_stat pu_stat_name = "ffreq_4"> </pu_stat>
</pu>
</popup_windows>
<supported_databases>
<database db_name="fpdb" db_server="mysql" db_ip="localhost" db_user="fpdb" db_pass="fpdb" db_type="fpdb"> </database>
<database db_name="fpdb" db_server="mysql" db_ip="localhost" db_user="fpdb" db_pass="YOUR MYSQL PASSWORD" db_type="fpdb"> </database>
</supported_databases>
<mucked_windows>
<mw mw_name="stud1" format="stud" rows="8" cols="11" deck="Cards01.png" card_wd="30" card_ht="42"> </mw>
</mucked_windows>
</FreePokerToolsConfig>

View File

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

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)

View File

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