diff --git a/pyfpdb/GuiAutoImport.py b/pyfpdb/GuiAutoImport.py index 97653c77..2c4246dc 100644 --- a/pyfpdb/GuiAutoImport.py +++ b/pyfpdb/GuiAutoImport.py @@ -124,14 +124,14 @@ class GuiAutoImport (threading.Thread): self.importer = fpdb_import.Importer(self,self.settings) self.importer.setCallHud(True) self.importer.setMinPrint(30) + self.importer.setQuiet(False) + self.importer.setFailOnError(False) + self.importer.setHandCount(0) self.server=settings['db-host'] self.user=settings['db-user'] self.password=settings['db-password'] self.database=settings['db-databaseName'] - self.quiet=False - self.failOnError=False - self.handCount=0 self.mainVBox=gtk.VBox(False,1) self.mainVBox.show() diff --git a/pyfpdb/GuiBulkImport.py b/pyfpdb/GuiBulkImport.py index 061e3848..4f3d7ef6 100644 --- a/pyfpdb/GuiBulkImport.py +++ b/pyfpdb/GuiBulkImport.py @@ -40,9 +40,9 @@ class GuiBulkImport (threading.Thread): self.handCount=self.hand_count_tbuffer.get_text(self.hand_count_tbuffer.get_start_iter(), self.hand_count_tbuffer.get_end_iter()) if (self.handCount=="unlimited" or self.handCount=="Unlimited"): - self.handCount=0 + self.importer.setHandCount(0) else: - self.handCount=int(self.handCount) + self.importer.setHandCount(int(self.handCount)) self.errorFile="failed.txt" @@ -54,15 +54,15 @@ class GuiBulkImport (threading.Thread): self.quiet=self.info_tbuffer.get_text(self.info_tbuffer.get_start_iter(), self.info_tbuffer.get_end_iter()) if (self.quiet=="yes"): - self.quiet=False + self.importer.setQuiet(False) else: - self.quiet=True + self.importer.setQuiet(True) self.failOnError=self.fail_error_tbuffer.get_text(self.fail_error_tbuffer.get_start_iter(), self.fail_error_tbuffer.get_end_iter()) if (self.failOnError=="no"): - self.failOnError=False + self.importer.setFailOnError(False) else: - self.failOnError=True + self.importer.setFailOnError(True) if os.path.isdir(self.inputFile): self.import_dir() diff --git a/pyfpdb/GuiTableViewer.py b/pyfpdb/GuiTableViewer.py index 2cccdbe5..f2bfecd9 100644 --- a/pyfpdb/GuiTableViewer.py +++ b/pyfpdb/GuiTableViewer.py @@ -251,11 +251,11 @@ class GuiTableViewer (threading.Thread): self.user=self.db.user self.password=self.db.password - self.quiet=False - self.failOnError=False - self.handCount=0 self.importer = fpdb_import.Importer(self, self.settings) self.importer.setMinPrint(0) + self.importer.setQuiet(False) + self.importer.setFailOnError(False) + self.importer.setHandCount(0) self.last_read_hand_id=self.importer.import_file_dict() #end def table_viewer.import_clicked diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index 5a2aaab5..9c2955eb 100755 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -83,6 +83,15 @@ class Importer: def setMinPrint(self, value): self.settings['minPrint'] = int(value) + def setHandCount(self, value): + self.settings['handCount'] = int(value) + + def setQuiet(self, value): + self.settings['quiet'] = value + + def setFailOnError(self, value): + self.settings['failOnError'] = value + def import_file_dict(self): starttime = time() last_read_hand=0 @@ -168,7 +177,7 @@ class Importer: errors+=1 self.printEmailErrorMessage(errors, self.caller.inputFile, hand[0]) - if (self.caller.failOnError): + if (self.settings['failOnError']): self.db.commit() #dont remove this, in case hand processing was cancelled. raise except (fpdb_simple.FpdbError), fe: @@ -178,16 +187,16 @@ class Importer: #fe.printStackTrace() #todo: get stacktrace self.db.rollback() - if (self.caller.failOnError): + if (self.settings['failOnError']): self.db.commit() #dont remove this, in case hand processing was cancelled. raise if (self.settings['minPrint']!=0): if ((stored+duplicates+partial+errors)%self.settings['minPrint']==0): print "stored:", stored, "duplicates:", duplicates, "partial:", partial, "errors:", errors - if (self.caller.handCount!=0): - if ((stored+duplicates+partial+errors)>=self.caller.handCount): - if (not self.caller.quiet): + if (self.settings['handCount']!=0): + if ((stored+duplicates+partial+errors)>=self.settings['handCount']): + if (not self.settings['quiet']): print "quitting due to reaching the amount of hands to be imported" print "Total stored:", stored, "duplicates:", duplicates, "partial/damaged:", partial, "errors:", errors, " time:", (time() - starttime) sys.exit(0)