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
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:

View File

@ -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) = ([], [], [], [], [], [])