From 64f46181fa5f2c95fc007677f5f747af1ace5f06 Mon Sep 17 00:00:00 2001 From: Chaz Littlejohn Date: Tue, 22 Mar 2011 03:22:38 +0000 Subject: [PATCH] Modified hhc & fpdb_import so gtk & pygtk are imported only if import is run from the gui --- pyfpdb/HandHistoryConverter.py | 12 ++++++------ pyfpdb/fpdb_import.py | 5 ++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py index b41f9342..3ac60136 100644 --- a/pyfpdb/HandHistoryConverter.py +++ b/pyfpdb/HandHistoryConverter.py @@ -50,8 +50,6 @@ import Hand from Exceptions import FpdbParseError import Configuration -import pygtk -import gtk class HandHistoryConverter(): @@ -128,9 +126,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 +177,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 df45bc63..62d2059f 100644 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -35,9 +35,6 @@ import logging # logging has been set up in fpdb.py or HUD_main.py, use their settings: log = logging.getLogger("importer") -import pygtk -import gtk - # fpdb/FreePokerTools modules import Database import Configuration @@ -261,6 +258,7 @@ class Importer: pass else: print _("waiting for writers to finish ...") + import gtk, pygtk #for t in threading.enumerate(): # print " "+str(t) #self.writeq.join() @@ -457,6 +455,7 @@ class Importer: self.pos_in_file[file] = 0 hhc = obj( self.config, in_path = file, index = idx, starsArchive = self.settings['starsArchive'], ftpArchive = self.settings['ftpArchive'], sitename = site ) if hhc.getStatus(): + if self.caller: hhc.progressNotify() handlist = hhc.getProcessedHands() self.pos_in_file[file] = hhc.getLastCharacterRead() to_hud = []