consolidate config files--default.conf no longer needed
This commit is contained in:
parent
8b86d22d68
commit
a719efc6dc
|
@ -169,6 +169,24 @@ class Popup:
|
|||
temp = temp + " " + stat
|
||||
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:
|
||||
def __init__(self, file = None):
|
||||
|
||||
|
@ -200,6 +218,7 @@ class Config:
|
|||
sys.stderr.write("No HUD_config_xml found. Exiting")
|
||||
sys.exit()
|
||||
try:
|
||||
print "Reading configuration file %s\n" % (file)
|
||||
doc = xml.dom.minidom.parse(file)
|
||||
except:
|
||||
print "Error parsing %s. See error log file." % (file)
|
||||
|
@ -221,26 +240,34 @@ class Config:
|
|||
site = Site(node = site_node)
|
||||
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"):
|
||||
game = Game(node = game_node)
|
||||
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"):
|
||||
db = Database(node = db_node)
|
||||
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"):
|
||||
mw = Mucked(node = mw_node)
|
||||
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"):
|
||||
pu = Popup(node = pu_node)
|
||||
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):
|
||||
for site_node in self.doc.getElementsByTagName("site"):
|
||||
if site_node.getAttribute("site_name") == site:
|
||||
|
@ -285,56 +312,94 @@ class Config:
|
|||
if name == None: name = 'fpdb'
|
||||
db = {}
|
||||
try:
|
||||
db['databaseName'] = name
|
||||
db['host'] = self.supported_databases[name].db_ip
|
||||
db['user'] = self.supported_databases[name].db_user
|
||||
db['password'] = self.supported_databases[name].db_pass
|
||||
db['server'] = self.supported_databases[name].db_server
|
||||
db['db-databaseName'] = name
|
||||
db['db-host'] = self.supported_databases[name].db_ip
|
||||
db['db-user'] = self.supported_databases[name].db_user
|
||||
db['db-password'] = self.supported_databases[name].db_pass
|
||||
db['db-server'] = self.supported_databases[name].db_server
|
||||
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':
|
||||
db['backend'] = 3
|
||||
else: db['backend'] = 0 # this is big trouble
|
||||
db['db-backend'] = 3
|
||||
else: db['db-backend'] = None # this is big trouble
|
||||
except:
|
||||
pass
|
||||
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__":
|
||||
c = Config()
|
||||
|
||||
print "\n----------- SUPPORTED SITES -----------"
|
||||
for s in c.supported_sites.keys():
|
||||
print c.supported_sites[s]
|
||||
|
||||
print "----------- END SUPPORTED SITES -----------"
|
||||
|
||||
|
||||
print "\n----------- SUPPORTED GAMES -----------"
|
||||
for game in c.supported_games.keys():
|
||||
print c.supported_games[game]
|
||||
|
||||
print "----------- END SUPPORTED GAMES -----------"
|
||||
|
||||
|
||||
print "\n----------- SUPPORTED DATABASES -----------"
|
||||
for db in c.supported_databases.keys():
|
||||
print c.supported_databases[db]
|
||||
|
||||
print "----------- END SUPPORTED DATABASES -----------"
|
||||
|
||||
print "\n----------- MUCKED WINDOW FORMATS -----------"
|
||||
for w in c.mucked_windows.keys():
|
||||
print c.mucked_windows[w]
|
||||
|
||||
print "----------- END MUCKED WINDOW FORMATS -----------"
|
||||
|
||||
|
||||
print "\n----------- POPUP WINDOW FORMATS -----------"
|
||||
for w in c.popup_windows.keys():
|
||||
print c.popup_windows[w]
|
||||
|
||||
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.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")
|
||||
|
|
|
@ -33,6 +33,7 @@ import GuiTableViewer
|
|||
import GuiAutoImport
|
||||
import GuiGraphViewer
|
||||
import FpdbSQLQueries
|
||||
import Configuration
|
||||
|
||||
class fpdb:
|
||||
def tab_clicked(self, widget, tab_name):
|
||||
|
@ -256,71 +257,16 @@ class fpdb:
|
|||
|
||||
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"}
|
||||
self.settings = {}
|
||||
if (os.sep=="/"):
|
||||
self.settings['os']="linuxmac"
|
||||
else:
|
||||
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['bulkImport-defaultPath']="C:\\Program Files\\PokerStars\\HandHistory\\filename.txt"
|
||||
self.settings['hud-defaultPath']="C:\\Program Files\\PokerStars\\HandHistory\\"
|
||||
else:
|
||||
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)
|
||||
|
||||
self.settings.update(self.config.get_db_parameters())
|
||||
self.settings.update(self.config.get_tv_parameters())
|
||||
self.settings.update(self.config.get_import_parameters())
|
||||
self.settings.update(self.config.get_default_paths())
|
||||
|
||||
if self.db!=None:
|
||||
self.db.disconnect()
|
||||
|
@ -355,8 +301,7 @@ class fpdb:
|
|||
#end def not_implemented
|
||||
|
||||
def obtain_global_lock(self):
|
||||
#print "todo: implement obtain_global_lock (users: pls ignore this)"
|
||||
pass
|
||||
print "todo: implement obtain_global_lock (users: pls ignore this)"
|
||||
#end def obtain_global_lock
|
||||
|
||||
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):
|
||||
self.threads=[]
|
||||
self.db=None
|
||||
self.config = Configuration.Config()
|
||||
self.load_default_profile()
|
||||
|
||||
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
||||
self.window.connect("delete_event", self.delete_event)
|
||||
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_size_request(1020,400)
|
||||
self.window.set_resizable(True)
|
||||
|
|
Loading…
Reference in New Issue
Block a user