Replayer: Add command line parsing for filename and site

This commit is contained in:
Worros 2010-12-17 16:50:32 +08:00
parent fd28ad3987
commit caab83e6b6

View File

@ -33,28 +33,38 @@ import gobject
class GuiReplayer: class GuiReplayer:
def __init__(self, config, querylist, mainwin, debug=True): def __init__(self, config, querylist, mainwin, options = None, debug=True):
self.debug = debug self.debug = debug
self.conf = config self.conf = config
self.main_window = mainwin self.main_window = mainwin
self.sql = querylist self.sql = querylist
# These are temporary variables until it becomes possible
# to select() a Hand object from the database
self.filename="regression-test-files/cash/Stars/Flop/NLHE-FR-USD-0.01-0.02-201005.microgrind.txt"
self.site="PokerStars"
if options.filename != None:
self.filename = options.filename
if options.sitename != None:
self.site = options.sitename
self.db = Database.Database(self.conf, sql=self.sql) self.db = Database.Database(self.conf, sql=self.sql)
filters_display = { "Heroes" : True, filters_display = { "Heroes" : True,
"Sites" : True, "Sites" : False,
"Games" : True, "Games" : False,
"Limits" : True, "Limits" : False,
"LimitSep" : True, "LimitSep" : False,
"LimitType" : True, "LimitType" : False,
"Type" : True, "Type" : False,
"Seats" : True, "Seats" : False,
"SeatSep" : True, "SeatSep" : False,
"Dates" : True, "Dates" : True,
"Groups" : True, "Groups" : False,
"GroupsAll" : True, "GroupsAll" : False,
"Button1" : True, "Button1" : True,
"Button2" : True "Button2" : False
} }
@ -239,27 +249,23 @@ class GuiReplayer:
be replaced by a function to select a hand from the db in the not so distant future. be replaced by a function to select a hand from the db in the not so distant future.
This code has been shamelessly stolen from Carl This code has been shamelessly stolen from Carl
""" """
config = Configuration.Config(file = "HUD_config.test.xml")
db = Database.Database(config)
sql = SQL.Sql(db_server = 'sqlite')
settings = {} settings = {}
settings.update(config.get_db_parameters()) settings.update(self.conf.get_db_parameters())
settings.update(config.get_import_parameters()) settings.update(self.conf.get_import_parameters())
settings.update(config.get_default_paths()) settings.update(self.conf.get_default_paths())
#db.recreate_tables()
importer = fpdb_import.Importer(False, settings, config, None) importer = fpdb_import.Importer(False, settings, self.conf, None)
importer.setDropIndexes("don't drop") importer.setDropIndexes("don't drop")
importer.setFailOnError(True) importer.setFailOnError(True)
importer.setThreads(-1) importer.setThreads(-1)
importer.setCallHud(False) importer.setCallHud(False)
importer.setFakeCacheHHC(True) importer.setFakeCacheHHC(True)
#Get a simple regression file with a few hands of Hold'em #Get a simple regression file with a few hands of Hold'em
filename="regression-test-files/cash/Stars/Flop/NLHE-FR-USD-0.01-0.02-201005.microgrind.txt" print "DEBUG: self.filename: '%s' self.site: '%s'" %(self.filename, self.site)
site="PokerStars"
importer.addBulkImportImportFileOrDir(self.filename, site=self.site)
importer.addBulkImportImportFileOrDir(filename, site=site)
(stored, dups, partial, errs, ttime) = importer.runImport() (stored, dups, partial, errs, ttime) = importer.runImport()
@ -288,24 +294,23 @@ def main(argv=None):
#Print usage examples and exit #Print usage examples and exit
sys.exit(0) sys.exit(0)
if options.sitename:
options.sitename = Options.site_alias(options.sitename)
if options.sitename == False:
usage()
config = Configuration.Config(file = "HUD_config.test.xml") config = Configuration.Config(file = "HUD_config.test.xml")
db = Database.Database(config) db = Database.Database(config)
sql = SQL.Sql(db_server = 'sqlite') sql = SQL.Sql(db_server = 'sqlite')
settings = {}
settings.update(config.get_db_parameters())
settings.update(config.get_import_parameters())
settings.update(config.get_default_paths())
main_window = gtk.Window() main_window = gtk.Window()
main_window.connect('destroy', destroy) main_window.connect('destroy', destroy)
replayer = GuiReplayer(config, sql, main_window, debug=True) replayer = GuiReplayer(config, sql, main_window, options=options, debug=True)
main_window.add(replayer.get_vbox()) main_window.add(replayer.get_vbox())
main_window.set_default_size(800,800) main_window.set_default_size(800,800)
main_window.show_all() main_window.show()
gtk.main() gtk.main()
if __name__ == '__main__': if __name__ == '__main__':