From 1be81ced660ee7faa38e7a2f72ebc984dd93f618 Mon Sep 17 00:00:00 2001 From: Worros Date: Fri, 27 Mar 2009 22:53:01 +0900 Subject: [PATCH 1/3] Allow dbname to be something other than fpdb Patch from Rune Nesheim to allow the dbname to be specified on the command line --- pyfpdb/Configuration.py | 9 ++++----- pyfpdb/fpdb.py | 6 ++++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py index 19e62038..0087e0b0 100755 --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -230,7 +230,7 @@ class Tv: (self.combinedStealFold, self.combined2B3B, self.combinedPostflop) ) class Config: - def __init__(self, file = None): + def __init__(self, file = None, dbname = 'fpdb'): # "file" is a path to an xml file with the fpdb/HUD configuration # we check the existence of "file" and try to recover if it doesn't exist @@ -308,7 +308,7 @@ class Config: tv = Tv(node = tv_node) self.tv = tv - db = self.get_db_parameters('fpdb') + db = self.get_db_parameters(dbname) if db['db-password'] == 'YOUR MYSQL PASSWORD': df_file = self.find_default_conf() if df_file == None: # this is bad @@ -448,8 +448,7 @@ class Config: else: self.aux_windows[aux_name].layout[max].location[i] = ( locations[i][0], locations[i][1] ) - def get_db_parameters(self, name = None): - if name == None: name = 'fpdb' + def get_db_parameters(self, name): db = {} try: db['db-databaseName'] = name except: pass @@ -713,7 +712,7 @@ if __name__== "__main__": c.edit_layout("PokerStars", 6, locations=( (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6) )) c.save(file="testout.xml") - print "db = ", c.get_db_parameters() + print "db = ", c.get_db_parameters('fpdb') # print "tv = ", c.get_tv_parameters() # print "imp = ", c.get_import_parameters() print "paths = ", c.get_default_paths("PokerStars") diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py index b5931bde..ddae31cc 100755 --- a/pyfpdb/fpdb.py +++ b/pyfpdb/fpdb.py @@ -23,6 +23,8 @@ from optparse import OptionParser parser = OptionParser() parser.add_option("-x", "--errorsToConsole", action="store_true", help="If passed error output will go to the console rather than .") +parser.add_option("-d", "--databaseName", dest="dbname", default="fpdb", + help="Overrides the default database name") (options, sys.argv) = parser.parse_args() if not options.errorsToConsole: @@ -250,7 +252,7 @@ class fpdb: else: self.settings['os']="windows" - self.settings.update(self.config.get_db_parameters()) + self.settings.update(self.config.get_db_parameters(options.dbname)) self.settings.update(self.config.get_tv_parameters()) self.settings.update(self.config.get_import_parameters()) self.settings.update(self.config.get_default_paths()) @@ -371,7 +373,7 @@ 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.config = Configuration.Config(dbname=options.dbname) self.load_profile() self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) From 7f0185d417b4876c542716c09fc52d266cd24d96 Mon Sep 17 00:00:00 2001 From: Worros Date: Fri, 27 Mar 2009 23:49:22 +0900 Subject: [PATCH 2/3] More fixes to allow dbnames other than fpdb --- pyfpdb/Configuration.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py index 0087e0b0..6e5aa693 100755 --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -234,6 +234,7 @@ class Config: # "file" is a path to an xml file with the fpdb/HUD configuration # we check the existence of "file" and try to recover if it doesn't exist + self.dbname = dbname self.default_config_path = self.get_default_config_path() if not file == None: # configuration file path has been passed @@ -308,7 +309,7 @@ class Config: tv = Tv(node = tv_node) self.tv = tv - db = self.get_db_parameters(dbname) + db = self.get_db_parameters() if db['db-password'] == 'YOUR MYSQL PASSWORD': df_file = self.find_default_conf() if df_file == None: # this is bad @@ -448,8 +449,9 @@ class Config: else: self.aux_windows[aux_name].layout[max].location[i] = ( locations[i][0], locations[i][1] ) - def get_db_parameters(self, name): + def get_db_parameters(self): db = {} + name = self.dbname try: db['db-databaseName'] = name except: pass @@ -712,7 +714,7 @@ if __name__== "__main__": c.edit_layout("PokerStars", 6, locations=( (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6) )) c.save(file="testout.xml") - print "db = ", c.get_db_parameters('fpdb') + 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") From b92022fecd5866415df6e10d8dc9d25f8322ffa8 Mon Sep 17 00:00:00 2001 From: Worros Date: Fri, 27 Mar 2009 23:53:44 +0900 Subject: [PATCH 3/3] Fix call to get_db_parameters --- pyfpdb/fpdb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py index ddae31cc..0f0f3bf3 100755 --- a/pyfpdb/fpdb.py +++ b/pyfpdb/fpdb.py @@ -252,7 +252,7 @@ class fpdb: else: self.settings['os']="windows" - self.settings.update(self.config.get_db_parameters(options.dbname)) + 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())