diff --git a/pyfpdb/GuiBulkImport.py b/pyfpdb/GuiBulkImport.py
index ab36aa15..c4f3105f 100755
--- a/pyfpdb/GuiBulkImport.py
+++ b/pyfpdb/GuiBulkImport.py
@@ -27,11 +27,13 @@ import traceback
import pygtk
pygtk.require('2.0')
import gtk
+import gobject
# fpdb/FreePokerTools modules
import fpdb_simple
import fpdb_import
import Configuration
+import Exceptions
class GuiBulkImport():
@@ -53,12 +55,22 @@ class GuiBulkImport():
else:
self.importer.RunImportThreaded()
+ def dopulse(self):
+ self.progressbar.pulse()
+ return True
+
def load_clicked(self, widget, data=None):
# Does the lock acquisition need to be more sophisticated for multiple dirs?
# (see comment above about what to do if pipe already open)
if self.settings['global_lock'].acquire(False): # returns false immediately if lock not acquired
try:
print "\nGlobal lock taken ..."
+ self.progressbar.set_text("Importing...")
+ self.progressbar.pulse()
+ while gtk.events_pending(): # see http://faq.pygtk.org/index.py?req=index for more hints (3.7)
+ gtk.main_iteration(False)
+ self.timer = gobject.timeout_add(100, self.dopulse)
+
# get the dir to import from the chooser
self.inputFile = self.chooser.get_filename()
@@ -74,9 +86,7 @@ class GuiBulkImport():
cb_hmodel = self.cb_drophudcache.get_model()
cb_hindex = self.cb_drophudcache.get_active()
- self.lab_info.set_markup('Importing ...') # uses pango markup!
- while gtk.events_pending(): # see http://faq.pygtk.org/index.py?req=index for more hints (3.7)
- gtk.main_iteration(False)
+ #self.lab_info.set_markup('Importing ...') # uses pango markup!
if cb_index:
self.importer.setDropIndexes(cb_model[cb_index][0])
@@ -91,7 +101,14 @@ class GuiBulkImport():
self.importer.addBulkImportImportFileOrDir(self.inputFile, site = sitename)
self.importer.setCallHud(False)
starttime = time()
- (stored, dups, partial, errs, ttime) = self.importer.runImport()
+ try:
+ (stored, dups, partial, errs, ttime) = self.importer.runImport()
+ except:
+ print "*** EXCEPTION DURING BULKIMPORT!!!"
+ raise Exceptions.FpdbError
+ finally:
+ gobject.source_remove(self.timer)
+
ttime = time() - starttime
if ttime == 0:
ttime = 1
@@ -106,7 +123,8 @@ class GuiBulkImport():
self.cb_drophudcache.set_active(0)
self.lab_hdrop.set_sensitive(True)
- self.lab_info.set_text("Import finished")
+ self.progressbar.set_text("Import Complete")
+ self.progressbar.set_fraction(0)
except:
err = traceback.extract_tb(sys.exc_info()[2])[-1]
print "***Error: "+err[2]+"("+str(err[1])+"): "+str(sys.exc_info()[1])
@@ -251,9 +269,14 @@ class GuiBulkImport():
self.lab_spacer.show()
# label - info
- self.lab_info = gtk.Label()
- self.table.attach(self.lab_info, 3, 5, 4, 5, xpadding = 0, ypadding = 0, yoptions=gtk.SHRINK)
- self.lab_info.show()
+# self.lab_info = gtk.Label()
+# self.table.attach(self.lab_info, 3, 5, 4, 5, xpadding = 0, ypadding = 0, yoptions=gtk.SHRINK)
+# self.lab_info.show()
+ self.progressbar = gtk.ProgressBar()
+ self.table.attach(self.progressbar, 3, 5, 4, 5, xpadding = 0, ypadding = 0, yoptions = gtk.SHRINK)
+ self.progressbar.set_text("Waiting...")
+ self.progressbar.set_fraction(0)
+ self.progressbar.show()
# see how many hands are in the db and adjust accordingly
tcursor = self.importer.database.cursor
diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py
index 47a68deb..1165dec8 100644
--- a/pyfpdb/HandHistoryConverter.py
+++ b/pyfpdb/HandHistoryConverter.py
@@ -40,6 +40,9 @@ import logging, logging.config
logging.config.fileConfig(os.path.join(sys.path[0],"logging.conf"))
log = logging.getLogger("parser")
+import pygtk
+import gtk
+
class HandHistoryConverter():
READ_CHUNK_SIZE = 10000 # bytes to read at a time from file in tail mode
@@ -124,6 +127,9 @@ If in follow mode, wait for more data to turn up.
Otherwise, finish at EOF.
"""
+ while gtk.events_pending():
+ gtk.main_iteration(False)
+
starttime = time.time()
if not self.sanityCheck():
log.warning("Failed sanity check")
diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py
index 2c333c2f..97237456 100644
--- a/pyfpdb/fpdb_import.py
+++ b/pyfpdb/fpdb_import.py
@@ -30,6 +30,9 @@ import Queue
from collections import deque # using Queue for now
import threading
+import pygtk
+import gtk
+
# fpdb/FreePokerTools modules
import fpdb_simple
@@ -377,6 +380,7 @@ class Importer:
# This is now an internal function that should not be called directly.
def import_file_dict(self, db, file, site, filter, q=None):
#print "import_file_dict"
+
if os.path.isdir(file):
self.addToDirList[file] = [site] + [filter]
return
@@ -485,7 +489,9 @@ class Importer:
"""Import an fpdb hand history held in the list lines, could be one hand or many"""
#db.lock_for_insert() # should be ok when using one thread, but doesn't help??
-
+ while gtk.events_pending():
+ gtk.main_iteration(False)
+
try: # sometimes we seem to be getting an empty self.lines, in which case, we just want to return.
firstline = lines[0]
except: