GTI: Add command line interface for Tourney Sumary import

This commit is contained in:
Worros 2010-11-10 19:23:03 +08:00
parent 31843deafe
commit 7e1fa36b3a

View File

@ -35,6 +35,7 @@ import gobject
# fpdb/FreePokerTools modules # fpdb/FreePokerTools modules
import Configuration import Configuration
import Options
from Exceptions import FpdbParseError from Exceptions import FpdbParseError
import logging import logging
@ -248,14 +249,12 @@ class SummaryImporter:
def main(argv=None): def main(argv=None):
"""main can also be called in the python interpreter, by supplying the command line as the argument.""" """main can also be called in the python interpreter, by supplying the command line as the argument."""
import SQL
if argv is None: if argv is None:
argv = sys.argv[1:] argv = sys.argv[1:]
(options, argv) = Options.fpdb_options() (options, argv) = Options.fpdb_options()
if not options.config:
options.config = Configuration.Config(file = "HUD_config.test.xml")
if options.usage == True: if options.usage == True:
#Print usage examples and exit #Print usage examples and exit
print _("USAGE:") print _("USAGE:")
@ -265,14 +264,28 @@ def main(argv=None):
print _("Need to define a converter") print _("Need to define a converter")
exit(0) exit(0)
config = Configuration.Config() config = Configuration.Config("HUD_config.test.xml")
db = Database.Database(config)
sql = SQL.Sql(db_server = 'sqlite') 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()) sys.exit(main())