From 7c31a190770cf4ed3170d12dcbbfdadd8a15c494 Mon Sep 17 00:00:00 2001 From: Chaz Littlejohn Date: Wed, 23 Mar 2011 19:34:15 +0000 Subject: [PATCH] Modified HHC so gtk & pygtk are imported to execute a callback only if import is run from the gui --- pyfpdb/HandHistoryConverter.py | 13 ++++++------- pyfpdb/fpdb_import.py | 1 + 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py index b41f9342..6d25d6aa 100644 --- a/pyfpdb/HandHistoryConverter.py +++ b/pyfpdb/HandHistoryConverter.py @@ -50,9 +50,6 @@ import Hand from Exceptions import FpdbParseError import Configuration -import pygtk -import gtk - class HandHistoryConverter(): READ_CHUNK_SIZE = 10000 # bytes to read at a time from file in tail mode @@ -128,9 +125,6 @@ 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")) @@ -182,7 +176,12 @@ Otherwise, finish at EOF. finally: if self.out_fh != sys.stdout: self.out_fh.close() - + + def progressNotify(self): + "A callback to the interface while events are pending" + import gtk, pygtk + while gtk.events_pending(): + gtk.main_iteration(False) def tailHands(self): """Generator of handTexts from a tailed file: diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index 7aab478c..a104d5ce 100644 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -453,6 +453,7 @@ class Importer: ,sitename = site ) if hhc.getStatus(): + if self.caller: hhc.progressNotify() handlist = hhc.getProcessedHands() self.pos_in_file[file] = hhc.getLastCharacterRead() (hbulk, hpbulk, habulk, hcbulk, phands, ihands) = ([], [], [], [], [], [])