Modified HHC so gtk & pygtk are imported to execute a callback only if import is run from the gui

This commit is contained in:
Chaz Littlejohn 2011-03-23 19:34:15 +00:00
parent 3e9dacf900
commit 7c31a19077
2 changed files with 7 additions and 7 deletions

View File

@ -50,9 +50,6 @@ import Hand
from Exceptions import FpdbParseError from Exceptions import FpdbParseError
import Configuration import Configuration
import pygtk
import gtk
class HandHistoryConverter(): class HandHistoryConverter():
READ_CHUNK_SIZE = 10000 # bytes to read at a time from file in tail mode 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. Otherwise, finish at EOF.
""" """
while gtk.events_pending():
gtk.main_iteration(False)
starttime = time.time() starttime = time.time()
if not self.sanityCheck(): if not self.sanityCheck():
log.warning(_("Failed sanity check")) log.warning(_("Failed sanity check"))
@ -183,6 +177,11 @@ Otherwise, finish at EOF.
if self.out_fh != sys.stdout: if self.out_fh != sys.stdout:
self.out_fh.close() 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): def tailHands(self):
"""Generator of handTexts from a tailed file: """Generator of handTexts from a tailed file:

View File

@ -453,6 +453,7 @@ class Importer:
,sitename = site ) ,sitename = site )
if hhc.getStatus(): if hhc.getStatus():
if self.caller: hhc.progressNotify()
handlist = hhc.getProcessedHands() handlist = hhc.getProcessedHands()
self.pos_in_file[file] = hhc.getLastCharacterRead() self.pos_in_file[file] = hhc.getLastCharacterRead()
(hbulk, hpbulk, habulk, hcbulk, phands, ihands) = ([], [], [], [], [], []) (hbulk, hpbulk, habulk, hcbulk, phands, ihands) = ([], [], [], [], [], [])