Merge branch 'master' of git://git.assembla.com/fpdboz.git

Fix accessing the decoder from the wrong object, causing the hud to not work, it should work again. yay.
This commit is contained in:
eblade 2008-10-25 05:36:18 -04:00
commit 0cd57facda
28 changed files with 277 additions and 231 deletions

View File

@ -169,6 +169,24 @@ class Popup:
temp = temp + " " + stat temp = temp + " " + stat
return temp + "\n" return temp + "\n"
class Import:
def __init__(self, node):
self.interval = node.getAttribute("interval")
self.callFpdbHud = node.getAttribute("callFpdbHud")
def __str__(self):
return " interval = %s\n callFpdbHud = %s\n" % (self.interval, self.callFpdbHud)
class Tv:
def __init__(self, node):
self.combinedStealFold = node.getAttribute("combinedStealFold")
self.combined2B3B = node.getAttribute("combined2B3B")
self.combinedPostflop = node.getAttribute("combinedPostflop")
def __str__(self):
return (" combinedStealFold = %s\n combined2B3B = %s\n combinedPostflop = %s\n" %
(self.combinedStealFold, self.combined2B3B, self.combinedPostflop) )
class Config: class Config:
def __init__(self, file = None): def __init__(self, file = None):
@ -200,6 +218,7 @@ class Config:
sys.stderr.write("No HUD_config_xml found. Exiting") sys.stderr.write("No HUD_config_xml found. Exiting")
sys.exit() sys.exit()
try: try:
print "Reading configuration file %s\n" % (file)
doc = xml.dom.minidom.parse(file) doc = xml.dom.minidom.parse(file)
except: except:
print "Error parsing %s. See error log file." % (file) print "Error parsing %s. See error log file." % (file)
@ -221,26 +240,34 @@ class Config:
site = Site(node = site_node) site = Site(node = site_node)
self.supported_sites[site.site_name] = site self.supported_sites[site.site_name] = site
s_games = doc.getElementsByTagName("supported_games") # s_games = doc.getElementsByTagName("supported_games")
for game_node in doc.getElementsByTagName("game"): for game_node in doc.getElementsByTagName("game"):
game = Game(node = game_node) game = Game(node = game_node)
self.supported_games[game.game_name] = game self.supported_games[game.game_name] = game
s_dbs = doc.getElementsByTagName("supported_databases") # s_dbs = doc.getElementsByTagName("supported_databases")
for db_node in doc.getElementsByTagName("database"): for db_node in doc.getElementsByTagName("database"):
db = Database(node = db_node) db = Database(node = db_node)
self.supported_databases[db.db_name] = db self.supported_databases[db.db_name] = db
s_dbs = doc.getElementsByTagName("mucked_windows") # s_dbs = doc.getElementsByTagName("mucked_windows")
for mw_node in doc.getElementsByTagName("mw"): for mw_node in doc.getElementsByTagName("mw"):
mw = Mucked(node = mw_node) mw = Mucked(node = mw_node)
self.mucked_windows[mw.name] = mw self.mucked_windows[mw.name] = mw
s_dbs = doc.getElementsByTagName("popup_windows") # s_dbs = doc.getElementsByTagName("popup_windows")
for pu_node in doc.getElementsByTagName("pu"): for pu_node in doc.getElementsByTagName("pu"):
pu = Popup(node = pu_node) pu = Popup(node = pu_node)
self.popup_windows[pu.name] = pu self.popup_windows[pu.name] = pu
for imp_node in doc.getElementsByTagName("import"):
imp = Import(node = imp_node)
self.imp = imp
for tv_node in doc.getElementsByTagName("tv"):
tv = Tv(node = tv_node)
self.tv = tv
def get_site_node(self, site): def get_site_node(self, site):
for site_node in self.doc.getElementsByTagName("site"): for site_node in self.doc.getElementsByTagName("site"):
if site_node.getAttribute("site_name") == site: if site_node.getAttribute("site_name") == site:
@ -285,56 +312,94 @@ class Config:
if name == None: name = 'fpdb' if name == None: name = 'fpdb'
db = {} db = {}
try: try:
db['databaseName'] = name db['db-databaseName'] = name
db['host'] = self.supported_databases[name].db_ip db['db-host'] = self.supported_databases[name].db_ip
db['user'] = self.supported_databases[name].db_user db['db-user'] = self.supported_databases[name].db_user
db['password'] = self.supported_databases[name].db_pass db['db-password'] = self.supported_databases[name].db_pass
db['server'] = self.supported_databases[name].db_server db['db-server'] = self.supported_databases[name].db_server
if string.lower(self.supported_databases[name].db_server) == 'mysql': if string.lower(self.supported_databases[name].db_server) == 'mysql':
db['backend'] = 2 db['db-backend'] = 2
elif string.lower(self.supported_databases[name].db_server) == 'postgresql': elif string.lower(self.supported_databases[name].db_server) == 'postgresql':
db['backend'] = 3 db['db-backend'] = 3
else: db['backend'] = 0 # this is big trouble else: db['db-backend'] = None # this is big trouble
except: except:
pass pass
return db return db
def get_tv_parameters(self):
tv = {}
try:
tv['combinedStealFold'] = self.tv.combinedStealFold
tv['combined2B3B'] = self.tv.combined2B3B
tv['combinedPostflop'] = self.tv.combinedPostflop
except: # Default tv parameters
tv['combinedStealFold'] = True
tv['combined2B3B'] = True
tv['combinedPostflop'] = True
return tv
def get_import_parameters(self):
imp = {}
try:
imp['imp-callFpdbHud'] = self.imp.callFpdbHud
imp['hud-defaultInterval'] = int(self.imp.interval)
except: # Default import parameters
imp['imp-callFpdbHud'] = True
imp['hud-defaultInterval'] = 10
return imp
def get_default_paths(self, site = "PokerStars"):
paths = {}
try:
paths['hud-defaultPath'] = os.path.expanduser(self.supported_sites[site].HH_path)
paths['bulkImport-defaultPath'] = os.path.expanduser(self.supported_sites[site].HH_path)
except:
paths['hud-defaultPath'] = "default"
paths['bulkImport-defaultPath'] = "default"
return paths
if __name__== "__main__": if __name__== "__main__":
c = Config() c = Config()
print "\n----------- SUPPORTED SITES -----------" print "\n----------- SUPPORTED SITES -----------"
for s in c.supported_sites.keys(): for s in c.supported_sites.keys():
print c.supported_sites[s] print c.supported_sites[s]
print "----------- END SUPPORTED SITES -----------" print "----------- END SUPPORTED SITES -----------"
print "\n----------- SUPPORTED GAMES -----------" print "\n----------- SUPPORTED GAMES -----------"
for game in c.supported_games.keys(): for game in c.supported_games.keys():
print c.supported_games[game] print c.supported_games[game]
print "----------- END SUPPORTED GAMES -----------" print "----------- END SUPPORTED GAMES -----------"
print "\n----------- SUPPORTED DATABASES -----------" print "\n----------- SUPPORTED DATABASES -----------"
for db in c.supported_databases.keys(): for db in c.supported_databases.keys():
print c.supported_databases[db] print c.supported_databases[db]
print "----------- END SUPPORTED DATABASES -----------" print "----------- END SUPPORTED DATABASES -----------"
print "\n----------- MUCKED WINDOW FORMATS -----------" print "\n----------- MUCKED WINDOW FORMATS -----------"
for w in c.mucked_windows.keys(): for w in c.mucked_windows.keys():
print c.mucked_windows[w] print c.mucked_windows[w]
print "----------- END MUCKED WINDOW FORMATS -----------" print "----------- END MUCKED WINDOW FORMATS -----------"
print "\n----------- POPUP WINDOW FORMATS -----------" print "\n----------- POPUP WINDOW FORMATS -----------"
for w in c.popup_windows.keys(): for w in c.popup_windows.keys():
print c.popup_windows[w] print c.popup_windows[w]
print "----------- END MUCKED WINDOW FORMATS -----------" print "----------- END MUCKED WINDOW FORMATS -----------"
print "\n----------- IMPORT -----------"
print c.imp
print "----------- END IMPORT -----------"
print "\n----------- TABLE VIEW -----------"
print c.tv
print "----------- END TABLE VIEW -----------"
c.edit_layout("PokerStars", 6, locations=( (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6) )) c.edit_layout("PokerStars", 6, locations=( (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6) ))
c.save(file="testout.xml") c.save(file="testout.xml")
print c.get_db_parameters() print "db = ", c.get_db_parameters()
print "tv = ", c.get_tv_parameters()
print "imp = ", c.get_import_parameters()
print "paths = ", c.get_default_paths("PokerStars")

View File

@ -27,10 +27,10 @@ import time
import fpdb_import import fpdb_import
class GuiAutoImport (threading.Thread): class GuiAutoImport (threading.Thread):
def browseClicked(self, widget, data): def starsBrowseClicked(self, widget, data):
"""runs when user clicks browse on auto import tab""" """runs when user clicks browse on auto import tab"""
#print "start of GuiAutoImport.browseClicked" #print "start of GuiAutoImport.starsBrowseClicked"
current_path=self.pathTBuffer.get_text(self.pathTBuffer.get_start_iter(), self.pathTBuffer.get_end_iter()) current_path=self.starsDirPath.get_text()
dia_chooser = gtk.FileChooserDialog(title="Please choose the path that you want to auto import", dia_chooser = gtk.FileChooserDialog(title="Please choose the path that you want to auto import",
action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER, action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
@ -42,11 +42,32 @@ class GuiAutoImport (threading.Thread):
response = dia_chooser.run() response = dia_chooser.run()
if response == gtk.RESPONSE_OK: if response == gtk.RESPONSE_OK:
#print dia_chooser.get_filename(), 'selected' #print dia_chooser.get_filename(), 'selected'
self.pathTBuffer.set_text(dia_chooser.get_filename()) self.starsDirPath.set_text(dia_chooser.get_filename())
elif response == gtk.RESPONSE_CANCEL: elif response == gtk.RESPONSE_CANCEL:
print 'Closed, no files selected' print 'Closed, no files selected'
dia_chooser.destroy() dia_chooser.destroy()
#end def GuiAutoImport.browseClicked #end def GuiAutoImport.starsBrowseClicked
def tiltBrowseClicked(self, widget, data):
"""runs when user clicks browse on auto import tab"""
#print "start of GuiAutoImport.tiltBrowseClicked"
current_path=self.tiltDirPath.get_text()
dia_chooser = gtk.FileChooserDialog(title="Please choose the path that you want to auto import",
action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
#dia_chooser.set_current_folder(pathname)
dia_chooser.set_filename(current_path)
#dia_chooser.set_select_multiple(select_multiple) #not in tv, but want this in bulk import
response = dia_chooser.run()
if response == gtk.RESPONSE_OK:
#print dia_chooser.get_filename(), 'selected'
self.tiltDirPath.set_text(dia_chooser.get_filename())
elif response == gtk.RESPONSE_CANCEL:
print 'Closed, no files selected'
dia_chooser.destroy()
#end def GuiAutoImport.tiltBrowseClicked
def do_import(self): def do_import(self):
"""Callback for timer to do an import iteration.""" """Callback for timer to do an import iteration."""
@ -85,24 +106,27 @@ class GuiAutoImport (threading.Thread):
# command = command + " %s" % (self.database) # command = command + " %s" % (self.database)
# print "command = ", command # print "command = ", command
# self.pipe_to_hud = os.popen(command, 'w') # self.pipe_to_hud = os.popen(command, 'w')
self.path=self.pathTBuffer.get_text(self.pathTBuffer.get_start_iter(), self.pathTBuffer.get_end_iter()) self.starspath=self.starsDirPath.get_text()
self.tiltpath=self.tiltDirPath.get_text()
# Add directory to importer object and set the initial mtime reference. # Add directory to importer object.
self.importer.addImportDirectory(self.path, True) self.importer.addImportDirectory(self.starspath, True)
self.importer.addImportDirectory(self.tiltpath, True)
self.do_import() self.do_import()
interval=int(self.intervalTBuffer.get_text(self.intervalTBuffer.get_start_iter(), self.intervalTBuffer.get_end_iter())) interval=int(self.intervalEntry.get_text())
gobject.timeout_add(interval*1000, self.do_import) gobject.timeout_add(interval*1000, self.do_import)
#end def GuiAutoImport.browseClicked #end def GuiAutoImport.startClicked
def get_vbox(self): def get_vbox(self):
"""returns the vbox of this thread""" """returns the vbox of this thread"""
return self.mainVBox return self.mainVBox
#end def get_vbox #end def get_vbox
def __init__(self, settings, debug=True): def __init__(self, settings, config, debug=True):
"""Constructor for GuiAutoImport""" """Constructor for GuiAutoImport"""
self.settings=settings self.settings=settings
self.config=config
self.importer = fpdb_import.Importer(self,self.settings) self.importer = fpdb_import.Importer(self,self.settings)
self.importer.setCallHud(True) self.importer.setCallHud(True)
self.importer.setMinPrint(30) self.importer.setMinPrint(30)
@ -127,32 +151,44 @@ class GuiAutoImport (threading.Thread):
self.settingsHBox.pack_start(self.intervalLabel) self.settingsHBox.pack_start(self.intervalLabel)
self.intervalLabel.show() self.intervalLabel.show()
self.intervalTBuffer=gtk.TextBuffer() self.intervalEntry=gtk.Entry()
self.intervalTBuffer.set_text(str(self.settings['hud-defaultInterval'])) self.intervalEntry.set_text(str(self.settings['hud-defaultInterval']))
self.intervalTView=gtk.TextView(self.intervalTBuffer) self.settingsHBox.pack_start(self.intervalEntry)
self.settingsHBox.pack_start(self.intervalTView) self.intervalEntry.show()
self.intervalTView.show()
self.pathHBox = gtk.HBox(False, 0) self.pathHBox = gtk.HBox(False, 0)
self.mainVBox.pack_start(self.pathHBox, False, True, 0) self.mainVBox.pack_start(self.pathHBox, False, True, 0)
self.pathHBox.show() self.pathHBox.show()
self.pathLabel = gtk.Label("Path to auto-import:") self.pathStarsLabel = gtk.Label("Path to PokerStars auto-import:")
self.pathHBox.pack_start(self.pathLabel, False, False, 0) self.pathHBox.pack_start(self.pathStarsLabel, False, False, 0)
self.pathLabel.show() self.pathStarsLabel.show()
self.pathTBuffer=gtk.TextBuffer() self.starsDirPath=gtk.Entry()
self.pathTBuffer.set_text(self.settings['hud-defaultPath']) paths = self.config.get_default_paths("PokerStars")
self.pathTView=gtk.TextView(self.pathTBuffer) self.starsDirPath.set_text(paths['hud-defaultPath'])
self.pathHBox.pack_start(self.pathTView, False, True, 0) self.pathHBox.pack_start(self.starsDirPath, False, True, 0)
self.pathTView.show() self.starsDirPath.show()
self.browseButton=gtk.Button("Browse...") self.browseButton=gtk.Button("Browse...")
self.browseButton.connect("clicked", self.browseClicked, "Browse clicked") self.browseButton.connect("clicked", self.starsBrowseClicked, "Browse clicked")
self.pathHBox.pack_end(self.browseButton, False, False, 0) self.pathHBox.pack_start(self.browseButton, False, False, 0)
self.browseButton.show() self.browseButton.show()
self.pathTiltLabel = gtk.Label("Path to Full Tilt auto-import:")
self.pathHBox.pack_start(self.pathTiltLabel, False, False, 0)
self.pathTiltLabel.show()
self.tiltDirPath=gtk.Entry()
paths = self.config.get_default_paths("Full Tilt")
self.tiltDirPath.set_text(paths['hud-defaultPath'])
self.pathHBox.pack_start(self.tiltDirPath, False, True, 0)
self.tiltDirPath.show()
self.browseButton=gtk.Button("Browse...")
self.browseButton.connect("clicked", self.tiltBrowseClicked, "Browse clicked")
self.pathHBox.pack_start(self.browseButton, False, False, 0)
self.browseButton.show()
self.startButton=gtk.Button("Start Autoimport") self.startButton=gtk.Button("Start Autoimport")
self.startButton.connect("clicked", self.startClicked, "start clicked") self.startButton.connect("clicked", self.startClicked, "start clicked")

View File

@ -76,9 +76,10 @@ class GuiBulkImport (threading.Thread):
print "todo: implement bulk import thread" print "todo: implement bulk import thread"
#end def run #end def run
def __init__(self, db, settings): def __init__(self, db, settings, config):
self.db=db self.db=db
self.settings=settings self.settings=settings
self.config=config
self.importer = fpdb_import.Importer(self,self.settings) self.importer = fpdb_import.Importer(self,self.settings)
self.vbox=gtk.VBox(False,1) self.vbox=gtk.VBox(False,1)

View File

@ -45,9 +45,9 @@ class GuiGraphViewer (threading.Thread):
try: self.canvas.destroy() try: self.canvas.destroy()
except AttributeError: pass except AttributeError: pass
name=self.nameTBuffer.get_text(self.nameTBuffer.get_start_iter(), self.nameTBuffer.get_end_iter()) name=self.nameEntry.get_text()
site=self.siteTBuffer.get_text(self.siteTBuffer.get_start_iter(), self.siteTBuffer.get_end_iter()) site=self.siteEntry.get_text()
if site=="PS": if site=="PS":
site=2 site=2
@ -101,7 +101,7 @@ class GuiGraphViewer (threading.Thread):
return line/100 return line/100
#end of def getRingProfitGraph #end of def getRingProfitGraph
def __init__(self, db, settings, querylist, debug=True): def __init__(self, db, settings, querylist, config, debug=True):
"""Constructor for GraphViewer""" """Constructor for GraphViewer"""
self.debug=debug self.debug=debug
#print "start of GraphViewer constructor" #print "start of GraphViewer constructor"
@ -121,21 +121,22 @@ class GuiGraphViewer (threading.Thread):
self.settingsHBox.pack_start(self.nameLabel) self.settingsHBox.pack_start(self.nameLabel)
self.nameLabel.show() self.nameLabel.show()
self.nameTBuffer=gtk.TextBuffer() self.nameEntry=gtk.Entry()
self.nameTBuffer.set_text("name") self.nameEntry.set_text("name")
self.nameTView=gtk.TextView(self.nameTBuffer) self.settingsHBox.pack_start(self.nameEntry)
self.settingsHBox.pack_start(self.nameTView) self.nameEntry.show()
self.nameTView.show()
self.siteLabel = gtk.Label("Site (PS or FTP):") self.siteLabel = gtk.Label("Site (PS or FTP):")
self.settingsHBox.pack_start(self.siteLabel) self.settingsHBox.pack_start(self.siteLabel)
self.siteLabel.show() self.siteLabel.show()
self.siteTBuffer=gtk.TextBuffer() self.siteEntry=gtk.Entry()
self.siteTBuffer.set_text("PS") self.siteEntry.set_text("PS")
self.siteTView=gtk.TextView(self.siteTBuffer) self.settingsHBox.pack_start(self.siteEntry)
self.settingsHBox.pack_start(self.siteTView) self.siteEntry.show()
self.siteTView.show()
#Note: Assumes PokerStars is in the config
self.nameEntry.set_text(config.supported_sites["PokerStars"].screen_name)
self.showButton=gtk.Button("Show/Refresh") self.showButton=gtk.Button("Show/Refresh")
self.showButton.connect("clicked", self.showClicked, "show clicked") self.showButton.connect("clicked", self.showClicked, "show clicked")

View File

@ -161,6 +161,9 @@
<pu_stat pu_stat_name="ffreq_4"> </pu_stat> <pu_stat pu_stat_name="ffreq_4"> </pu_stat>
</pu> </pu>
</popup_windows> </popup_windows>
<import callFpdbHud = "True" interval = "10" ></import>
<tv combinedStealFold = "True" combined2B3B = "True" combinedPostflop = "True"></tv>
<supported_databases> <supported_databases>
<database db_name="fpdb" db_server="mysql" db_ip="localhost" db_user="fpdb" db_pass="YOUR MYSQL PASSWORD" 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> </supported_databases>

90
pyfpdb/HUD_main.py Executable file → Normal file
View File

@ -36,7 +36,8 @@ Main for FreePokerTools HUD.
import sys import sys
import os import os
import thread import thread
import Queue import time
import string
errorfile = open('HUD-error.txt', 'w', 0) errorfile = open('HUD-error.txt', 'w', 0)
sys.stderr = errorfile sys.stderr = errorfile
@ -61,54 +62,61 @@ config = 0;
def destroy(*args): # call back for terminating the main eventloop def destroy(*args): # call back for terminating the main eventloop
gtk.main_quit() gtk.main_quit()
def process_new_hand(new_hand_id, db_name): def create_HUD(new_hand_id, table, db_name, table_name, max, poker_game, db_connection, config, stat_dict):
# there is a new hand_id to be processed global hud_dict
# read the hand_id from stdin and strip whitespace def idle_func():
global hud_dict
gtk.gdk.threads_enter()
try:
hud_dict[table_name] = Hud.Hud(table, max, poker_game, config, db_name)
hud_dict[table_name].create(new_hand_id, config)
hud_dict[table_name].update(new_hand_id, config, stat_dict)
return False
finally:
gtk.gdk.threads_leave
gobject.idle_add(idle_func)
def update_HUD(new_hand_id, table_name, config, stat_dict):
global hud_dict
def idle_func():
gtk.gdk.threads_enter()
try:
hud_dict[table_name].update(new_hand_id, config, stat_dict)
return False
finally:
gtk.gdk.threads_leave
gobject.idle_add(idle_func)
def read_stdin(): # This is the thread function
global hud_dict global hud_dict
while True: # wait for a new hand number on stdin
new_hand_id = sys.stdin.readline()
new_hand_id = string.rstrip(new_hand_id)
if new_hand_id == "": # blank line means quit
destroy()
# delete hud_dict entries for any HUD destroyed since last iteration
for h in hud_dict.keys(): for h in hud_dict.keys():
if hud_dict[h].deleted: if hud_dict[h].deleted:
del(hud_dict[h]) del(hud_dict[h])
# connect to the db and get basic info about the new hand
db_connection = Database.Database(config, db_name, 'temp') db_connection = Database.Database(config, db_name, 'temp')
(table_name, max, poker_game) = db_connection.get_table_name(new_hand_id) (table_name, max, poker_game) = db_connection.get_table_name(new_hand_id)
stat_dict = db_connection.get_stats_from_hand(new_hand_id)
db_connection.close_connection()
# if a hud for this table exists, just update it # if a hud for this table exists, just update it
if hud_dict.has_key(table_name): if hud_dict.has_key(table_name):
hud_dict[table_name].update(new_hand_id, db_connection, config) update_HUD(new_hand_id, table_name, config, stat_dict)
# otherwise create a new hud # otherwise create a new hud
else: else:
tablewindow = Tables.discover_table_by_name(config, table_name) tablewindow = Tables.discover_table_by_name(config, table_name)
if tablewindow == None: if tablewindow == None:
sys.stderr.write("table name "+table_name+" not found\n") sys.stderr.write("table name "+table_name+" not found\n")
else: else:
hud_dict[table_name] = Hud.Hud(tablewindow, max, poker_game, config, db_name) create_HUD(new_hand_id, tablewindow, db_name, table_name, max, poker_game, db_connection, config, stat_dict)
hud_dict[table_name].create(new_hand_id, config)
hud_dict[table_name].update(new_hand_id, db_connection, config)
db_connection.close_connection()
return(1)
def check_stdin(db_name):
try:
hand_no = dataQueue.get(block=False)
process_new_hand(hand_no, db_name)
except:
pass
return True
def read_stdin(source, condition, db_name):
new_hand_id = sys.stdin.readline()
if new_hand_id == "":
destroy()
process_new_hand(new_hand_id, db_name)
return True
def producer(): # This is the thread function
while True:
hand_no = sys.stdin.readline() # reads stdin
if hand_no == "":
destroy()
dataQueue.put(hand_no) # and puts result on the queue
if __name__== "__main__": if __name__== "__main__":
sys.stderr.write("HUD_main starting\n") sys.stderr.write("HUD_main starting\n")
@ -120,24 +128,18 @@ if __name__== "__main__":
sys.stderr.write("Using db name = %s\n" % (db_name)) sys.stderr.write("Using db name = %s\n" % (db_name))
config = Configuration.Config() config = Configuration.Config()
# db_connection = Database.Database(config, 'fpdb', 'holdem')
if os.name == 'posix':
s_id = gobject.io_add_watch(sys.stdin, gobject.IO_IN, read_stdin, db_name)
elif os.name == 'nt':
dataQueue = Queue.Queue() # shared global. infinite size
gobject.threads_init() # this is required gobject.threads_init() # this is required
thread.start_new_thread(producer, ()) # starts the thread thread.start_new_thread(read_stdin, ()) # starts the thread
gobject.timeout_add(1000, check_stdin, db_name)
else:
print "Sorry your operating system is not supported."
sys.exit()
main_window = gtk.Window() main_window = gtk.Window()
main_window.connect("destroy", destroy) main_window.connect("destroy", destroy)
eb = gtk.EventBox()
label = gtk.Label('Closing this window will exit from the HUD.') label = gtk.Label('Closing this window will exit from the HUD.')
main_window.add(label) eb.add(label)
main_window.add(eb)
main_window.set_title("HUD Main Window") main_window.set_title("HUD Main Window")
main_window.show_all() main_window.show_all()
gtk.main() gtk.main()

View File

@ -53,6 +53,7 @@ class Hud:
self.max = max self.max = max
self.db_name = db_name self.db_name = db_name
self.deleted = False self.deleted = False
self.stacked = True
self.stat_windows = {} self.stat_windows = {}
self.popup_windows = {} self.popup_windows = {}
@ -68,7 +69,8 @@ class Hud:
#self.main_window.set_transient_for(parent.get_toplevel()) #self.main_window.set_transient_for(parent.get_toplevel())
self.ebox = gtk.EventBox() self.ebox = gtk.EventBox()
self.label = gtk.Label("Close this window to\nkill the HUD for\n %s" % (table.name)) self.label = gtk.Label("Close this window to\nkill the HUD for\n %s\nMinimizing it hides stats." %
(table.name))
self.main_window.add(self.ebox) self.main_window.add(self.ebox)
self.ebox.add(self.label) self.ebox.add(self.label)
self.main_window.move(self.table.x, self.table.y) self.main_window.move(self.table.x, self.table.y)
@ -211,9 +213,8 @@ class Hud:
# self.m = Mucked.Mucked(self.mucked_window, self.db_connection) # self.m = Mucked.Mucked(self.mucked_window, self.db_connection)
# self.mucked_window.show_all() # self.mucked_window.show_all()
def update(self, hand, db, config): def update(self, hand, config, stat_dict):
self.hand = hand # this is the last hand, so it is available later self.hand = hand # this is the last hand, so it is available later
stat_dict = db.get_stats_from_hand(hand)
for s in stat_dict.keys(): for s in stat_dict.keys():
self.stat_windows[stat_dict[s]['seat']].player_id = stat_dict[s]['player_id'] self.stat_windows[stat_dict[s]['seat']].player_id = stat_dict[s]['player_id']
for r in range(0, config.supported_games[self.poker_game].rows): for r in range(0, config.supported_games[self.poker_game].rows):

View File

@ -64,7 +64,8 @@ def discover(c):
tables = discover_nt(c) tables = discover_nt(c)
elif os.name == 'mac': elif os.name == 'mac':
tables = discover_mac(c) tables = discover_mac(c)
else: tables = {} else:
tables = {}
return(tables) return(tables)
@ -75,7 +76,8 @@ def discover_table_by_name(c, tablename):
table = discover_nt_by_name(c, tablename) table = discover_nt_by_name(c, tablename)
elif os.name == 'mac': elif os.name == 'mac':
table = discover_mac_by_name(c, tablename) table = discover_mac_by_name(c, tablename)
else: table = None else:
table = None
return(table) return(table)
def discover_posix(c): def discover_posix(c):
@ -211,7 +213,7 @@ def discover_nt_by_name(c, tablename):
tw.x = int(x) + b_width tw.x = int(x) + b_width
tw.y = int(y) + tb_height tw.y = int(y) + tb_height
tw.site = c.supported_sites[s].site_name tw.site = c.supported_sites[s].site_name
if not tw.site == "Unknown" and not tw.decoder == "Unknown": if not tw.site == "Unknown" and not c.supported_sites[tw.site].decoder == "Unknown":
eval("%s(tw)" % c.supported_sites[tw.site].decoder) eval("%s(tw)" % c.supported_sites[tw.site].decoder)
else: else:
tw.name = tablename tw.name = tablename
@ -291,9 +293,9 @@ def fulltilt_decode_table(tw):
title_bits = re.split(' - ', tw.title) title_bits = re.split(' - ', tw.title)
name = title_bits[0] name = title_bits[0]
tw.tournament = None tw.tournament = None
for pattern in [r' \(6 max\)', r' \(heads up\)', r' \(deep\)', for pattern in [' (6 max)', ' (heads up)', ' (deep)',
r' \(deep hu\)', r' \(deep 6\)', r' \(2\)', ' (deep hu)', ' (deep 6)', ' (2)',
r' \(edu\)', r' \(edu, 6 max\)', r' \(6\)' ]: ' (edu)', ' (edu, 6 max)', ' (6)' ]:
name = re.sub(pattern, '', name) name = re.sub(pattern, '', name)
# (tw.name, trash) = name.split(r' (', 1) # (tw.name, trash) = name.split(r' (', 1)
tw.name = name.rstrip() tw.name = name.rstrip()

View File

@ -33,6 +33,7 @@ import GuiTableViewer
import GuiAutoImport import GuiAutoImport
import GuiGraphViewer import GuiGraphViewer
import FpdbSQLQueries import FpdbSQLQueries
import Configuration
class fpdb: class fpdb:
def tab_clicked(self, widget, tab_name): def tab_clicked(self, widget, tab_name):
@ -236,91 +237,18 @@ class fpdb:
return self.item_factory.get_widget("<main>") return self.item_factory.get_widget("<main>")
#end def get_menu #end def get_menu
def load_default_profile(self): def load_profile(self):
"""Loads the defaut profile""" """Loads profile from the provided path name."""
defaultpath=os.path.expanduser("~") self.settings = {}
if not defaultpath.endswith(os.sep):#todo: check if this is needed in *nix, if not delete it
defaultpath+=(os.sep)
if (os.sep=="\\"):#ie. if Windows use application data folder
defaultpath=os.environ["APPDATA"]+os.sep
else:#ie. if POSIX OS prefix fpdb with a .
defaultpath+="."
defaultpath+=("fpdb"+os.sep+"default.conf")
if os.path.exists(defaultpath):
self.load_profile(defaultpath)
else:
self.diaSetupWizard(path=defaultpath)
#end def load_default_profile
def load_profile(self, filename):
"""Loads profile from the provided path name. also see load_default_profile"""
self.obtain_global_lock()
file=open(filename, "rU")
lines=file.readlines()
print "Opened and read profile file", filename
self.profile=filename
self.settings={'db-host':"localhost", 'db-backend':2, 'db-databaseName':"fpdb", 'db-user':"fpdb"}
if (os.sep=="/"): if (os.sep=="/"):
self.settings['os']="linuxmac" self.settings['os']="linuxmac"
else: else:
self.settings['os']="windows" self.settings['os']="windows"
self.settings['tv-combinedStealFold']=True
self.settings['tv-combined2B3B']=True
self.settings['imp-callFpdbHud']=True
if self.settings['os']=="windows": self.settings.update(self.config.get_db_parameters())
self.settings['bulkImport-defaultPath']="C:\\Program Files\\PokerStars\\HandHistory\\filename.txt" self.settings.update(self.config.get_tv_parameters())
self.settings['hud-defaultPath']="C:\\Program Files\\PokerStars\\HandHistory\\" self.settings.update(self.config.get_import_parameters())
else: self.settings.update(self.config.get_default_paths())
self.settings['bulkImport-defaultPath'] = os.path.expanduser("~") + "/.wine/drive_c/Program Files/PokerStars/HandHistory/filename.txt"
self.settings['hud-defaultPath'] = os.path.expanduser("~")+"/.wine/drive_c/Program Files/PokerStars/HandHistory/"
self.settings['hud-defaultInterval']=10
for i in range(len(lines)):
if lines[i].startswith("db-backend="):
self.settings['db-backend']=int(lines[i][11:-1])
elif lines[i].startswith("db-host="):
self.settings['db-host']=lines[i][8:-1]
elif lines[i].startswith("db-databaseName="):
self.settings['db-databaseName']=lines[i][16:-1]
elif lines[i].startswith("db-user="):
self.settings['db-user']=lines[i][8:-1]
elif lines[i].startswith("db-password="):
self.settings['db-password']=lines[i][12:-1]
elif lines[i].startswith("imp-callFpdbHud="):
if lines[i].find("True")!=-1:
self.settings['imp-callFpdbHud']=True
else:
self.settings['imp-callFpdbHud']=False
elif lines[i].startswith("tv-combinedPostflop="):
if lines[i].find("True")!=-1:
self.settings['tv-combinedPostflop']=True
else:
self.settings['tv-combinedPostflop']=False
elif lines[i].startswith("tv-combinedStealFold="):
if lines[i].find("True")!=-1:
self.settings['tv-combinedStealFold']=True
else:
self.settings['tv-combinedStealFold']=False
elif lines[i].startswith("tv-combined2B3B="):
if lines[i].find("True")!=-1:
self.settings['tv-combined2B3B']=True
else:
self.settings['tv-combined2B3B']=False
elif lines[i].startswith("bulkImport-defaultPath="):
if lines[i][23:-1]!="default":
self.settings['bulkImport-defaultPath']=lines[i][23:-1]
elif lines[i].startswith("hud-defaultPath="):
if lines[i][15:-1]!="default":
self.settings['hud-defaultPath']=lines[i][16:-1]
elif lines[i].startswith("#"):
pass #comment - dont parse
else:
raise fpdb_simple.FpdbError("invalid line in profile file: "+lines[i]+" if you don't know what to do just remove it from "+filename)
if self.db!=None: if self.db!=None:
self.db.disconnect() self.db.disconnect()
@ -355,8 +283,7 @@ class fpdb:
#end def not_implemented #end def not_implemented
def obtain_global_lock(self): def obtain_global_lock(self):
#print "todo: implement obtain_global_lock (users: pls ignore this)" print "todo: implement obtain_global_lock (users: pls ignore this)"
pass
#end def obtain_global_lock #end def obtain_global_lock
def quit(self, widget, data): def quit(self, widget, data):
@ -376,7 +303,7 @@ class fpdb:
def tab_auto_import(self, widget, data): def tab_auto_import(self, widget, data):
"""opens the auto import tab""" """opens the auto import tab"""
new_aimp_thread=GuiAutoImport.GuiAutoImport(self.settings) new_aimp_thread=GuiAutoImport.GuiAutoImport(self.settings, self.config)
self.threads.append(new_aimp_thread) self.threads.append(new_aimp_thread)
aimp_tab=new_aimp_thread.get_vbox() aimp_tab=new_aimp_thread.get_vbox()
self.add_and_display_tab(aimp_tab, "Auto Import") self.add_and_display_tab(aimp_tab, "Auto Import")
@ -385,7 +312,7 @@ class fpdb:
def tab_bulk_import(self, widget, data): def tab_bulk_import(self, widget, data):
"""opens a tab for bulk importing""" """opens a tab for bulk importing"""
#print "start of tab_bulk_import" #print "start of tab_bulk_import"
new_import_thread=GuiBulkImport.GuiBulkImport(self.db, self.settings) new_import_thread=GuiBulkImport.GuiBulkImport(self.db, self.settings, self.config)
self.threads.append(new_import_thread) self.threads.append(new_import_thread)
bulk_tab=new_import_thread.get_vbox() bulk_tab=new_import_thread.get_vbox()
self.add_and_display_tab(bulk_tab, "Bulk Import") self.add_and_display_tab(bulk_tab, "Bulk Import")
@ -412,7 +339,7 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt")
def tabGraphViewer(self, widget, data): def tabGraphViewer(self, widget, data):
"""opens a graph viewer tab""" """opens a graph viewer tab"""
#print "start of tabGraphViewer" #print "start of tabGraphViewer"
new_gv_thread=GuiGraphViewer.GuiGraphViewer(self.db, self.settings,self.querydict) new_gv_thread=GuiGraphViewer.GuiGraphViewer(self.db, self.settings, self.querydict, self.config)
self.threads.append(new_gv_thread) self.threads.append(new_gv_thread)
gv_tab=new_gv_thread.get_vbox() gv_tab=new_gv_thread.get_vbox()
self.add_and_display_tab(gv_tab, "Graphs") self.add_and_display_tab(gv_tab, "Graphs")
@ -421,12 +348,13 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt")
def __init__(self): def __init__(self):
self.threads=[] self.threads=[]
self.db=None self.db=None
self.load_default_profile() self.config = Configuration.Config()
self.load_profile()
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.connect("delete_event", self.delete_event) self.window.connect("delete_event", self.delete_event)
self.window.connect("destroy", self.destroy) self.window.connect("destroy", self.destroy)
self.window.set_title("Free Poker DB - version: alpha8, p137") self.window.set_title("Free Poker DB - version: alpha8+, p137 or higher")
self.window.set_border_width(1) self.window.set_border_width(1)
self.window.set_size_request(1020,400) self.window.set_size_request(1020,400)
self.window.set_resizable(True) self.window.set_resizable(True)

View File

@ -104,14 +104,14 @@ class Importer:
#Add an individual file to filelist #Add an individual file to filelist
def addImportFile(self, filename): def addImportFile(self, filename):
#todo: test it is a valid file #TODO: test it is a valid file
self.filelist = self.filelist + [filename] self.filelist = self.filelist + [filename]
#Remove duplicates #Remove duplicates
self.filelist = list(set(self.filelist)) self.filelist = list(set(self.filelist))
#Add a directory of files to filelist #Add a directory of files to filelist
def addImportDirectory(self,dir,monitor = False): def addImportDirectory(self,dir,monitor = False):
#todo: test it is a valid directory if os.path.isdir(dir):
if monitor == True: if monitor == True:
self.monitor = True self.monitor = True
self.dirlist = self.dirlist + [dir] self.dirlist = self.dirlist + [dir]
@ -123,6 +123,8 @@ class Importer:
self.filelist = self.filelist + [os.path.join(dir, file)] self.filelist = self.filelist + [os.path.join(dir, file)]
#Remove duplicates #Remove duplicates
self.filelist = list(set(self.filelist)) self.filelist = list(set(self.filelist))
else:
print "Warning: Attempted to add: '" + str(dir) + "' as an import directory"
#Run full import on filelist #Run full import on filelist
def runImport(self): def runImport(self):

0
website/contact.php Normal file → Executable file
View File

0
website/docs-abreviations.php Normal file → Executable file
View File

0
website/docs-benchmarks.php Normal file → Executable file
View File

0
website/docs-git-instructions.php Normal file → Executable file
View File

0
website/docs-hudHowTo.php Normal file → Executable file
View File

0
website/docs-install-gentoo.php Normal file → Executable file
View File

9
website/docs-install-windows.php Normal file → Executable file
View File

@ -9,12 +9,17 @@ require 'sidebar.php';
<div id="main"> <div id="main">
<h1>Before You Begin</h1>
<p>Most people should install using the <a href="http://sourceforge.net/project/showfiles.php?group_id=226872">Installer</a>. These instructions have not been updated recently, but can serve as a guide to someone who knows what he is doing. Unless you have a special reason for installing manually, you really should be using the installer.</p>
<h1>Vista Users</h1>
<p>The installer does not install mysql properly on Microsoft Vista installations, due to the UAC. You should first install mysql using this <a href="http://port25.technet.com/videos/research/MySQL_Windows.pdf">how to (pdf)</a>. Then run the installer. The installer will detect the mysql installation and not reintstall.</p>
<h1>Installing in Windows</h1> <h1>Installing in Windows</h1>
<div class="winInst"> <div class="winInst">
<p>These instructions were made with Windows XP. They should also work with Windows NT / 2000 / 2003 / Vista and 2008. Please report any differences to gmic at users.sourceforge.net. <p>These instructions were made with Windows XP. They should also work with Windows NT / 2000 / 2003 and 2008. Please report any differences to gmic at users.sourceforge.net.
<p>If you're still using Win3/95/98/ME then you should switch to GNU/Linux, *BSD or WinXP.</p> <p>If you're still using Win3/95/98/ME then you should switch to GNU/Linux, *BSD or WinXP.</p>
<p>An Installer will be made at some point.</p>
<div class="screenshot"> <div class="screenshot">
<img src="img/00.mySqlWebsite1.jpg" alt="windows install guide screenshot" /> <img src="img/00.mySqlWebsite1.jpg" alt="windows install guide screenshot" />

0
website/docs-overview.php Normal file → Executable file
View File

0
website/docs-requirements.php Normal file → Executable file
View File

0
website/docs-usage.php Normal file → Executable file
View File

0
website/docs.php Normal file → Executable file
View File

0
website/features.php Normal file → Executable file
View File

0
website/footer.php Normal file → Executable file
View File

0
website/header.php Normal file → Executable file
View File

0
website/index.php Normal file → Executable file
View File

0
website/license.php Normal file → Executable file
View File

0
website/screenshots.php Normal file → Executable file
View File

0
website/sidebar.php Normal file → Executable file
View File