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

This commit is contained in:
Worros 2008-10-22 19:10:37 +08:00
commit 53e7ed44b1
2 changed files with 94 additions and 83 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

@ -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):
@ -256,71 +257,16 @@ class fpdb:
def load_profile(self, filename): def load_profile(self, filename):
"""Loads profile from the provided path name. also see load_default_profile""" """Loads profile from the provided path name. also see load_default_profile"""
self.obtain_global_lock() self.settings = {}
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 +301,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):
@ -421,12 +366,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.config = Configuration.Config()
self.load_default_profile() self.load_default_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: alpha6+, p124 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)