From 7e1fa36b3acf13bd282b24a89c1f66ba9167e503 Mon Sep 17 00:00:00 2001 From: Worros Date: Wed, 10 Nov 2010 19:23:03 +0800 Subject: [PATCH] GTI: Add command line interface for Tourney Sumary import --- pyfpdb/GuiTourneyImport.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/pyfpdb/GuiTourneyImport.py b/pyfpdb/GuiTourneyImport.py index ba6d5bb1..bb2731b3 100755 --- a/pyfpdb/GuiTourneyImport.py +++ b/pyfpdb/GuiTourneyImport.py @@ -35,6 +35,7 @@ import gobject # fpdb/FreePokerTools modules import Configuration +import Options from Exceptions import FpdbParseError import logging @@ -248,14 +249,12 @@ class SummaryImporter: def main(argv=None): """main can also be called in the python interpreter, by supplying the command line as the argument.""" + import SQL if argv is None: argv = sys.argv[1:] (options, argv) = Options.fpdb_options() - if not options.config: - options.config = Configuration.Config(file = "HUD_config.test.xml") - if options.usage == True: #Print usage examples and exit print _("USAGE:") @@ -265,14 +264,28 @@ def main(argv=None): print _("Need to define a converter") exit(0) - config = Configuration.Config() - db = Database.Database(config) + config = Configuration.Config("HUD_config.test.xml") sql = SQL.Sql(db_server = 'sqlite') - db.recreate_tables() + if options.filename == None: + print _("Need a filename to import") + exit(0) + + importer = SummaryImporter(config, sql, None) + + importer.addImportFileOrDir(options.filename, site = options.hhc) + starttime = time() + (stored, errs) = importer.runImport() + + ttime = time() - starttime + if ttime == 0: + ttime = 1 + print _('GuiTourneyImport.load done: Stored: %d\tErrors: %d in %s seconds - %.0f/sec')\ + % (stored, errs, ttime, (stored+0.0) / ttime) + importer.clearFileList() -if __name__ == '__main__': +if __name__ == '__main__': sys.exit(main())