From 733b4f5594fef4e0943fc4de3c602ecf61a87e97 Mon Sep 17 00:00:00 2001 From: Worros Date: Thu, 7 Oct 2010 13:02:36 +0800 Subject: [PATCH] AutoImport: Start refactor so it can run from the comand line --- pyfpdb/GuiAutoImport.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/pyfpdb/GuiAutoImport.py b/pyfpdb/GuiAutoImport.py index 2ff70ca8..8cbe8d19 100755 --- a/pyfpdb/GuiAutoImport.py +++ b/pyfpdb/GuiAutoImport.py @@ -45,7 +45,7 @@ if os.name == "nt": class GuiAutoImport (threading.Thread): - def __init__(self, settings, config, sql, parent): + def __init__(self, settings, config, sql = None, parent = None, cli = False): self.importtimer = 0 self.settings = settings self.config = config @@ -54,9 +54,6 @@ class GuiAutoImport (threading.Thread): imp = self.config.get_import_parameters() -# print "Import parameters" -# print imp - self.input_settings = {} self.pipe_to_hud = None @@ -66,13 +63,21 @@ class GuiAutoImport (threading.Thread): self.importer.setQuiet(False) self.importer.setFailOnError(False) self.importer.setHandCount(0) -# self.importer.setWatchTime() self.server = settings['db-host'] self.user = settings['db-user'] self.password = settings['db-password'] self.database = settings['db-databaseName'] + if cli == False: + self.setupGui() + else: + # TODO: Separate the code that grabs the directories from config + # Separate the calls to the Importer API + # Create a timer interface that doesn't rely on GTK + pass + + def setupGui(self): self.mainVBox = gtk.VBox(False,1) hbox = gtk.HBox(True, 0) # contains 2 equal vboxes @@ -343,7 +348,7 @@ if __name__== "__main__": if os.name == 'nt': settings['os'] = 'windows' else: settings['os'] = 'linuxmac' - settings.update(config.get_db_parameters('fpdb')) + settings.update(config.get_db_parameters()) settings.update(config.get_import_parameters()) settings.update(config.get_default_paths()) @@ -355,4 +360,4 @@ if __name__== "__main__": main_window.show() gtk.main() else: - pass + i = GuiAutoImport(settings, config, cli = True)