From 837005d56586420e118d1bc16cef2cfad061a729 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Sat, 25 Apr 2009 10:02:51 +0000 Subject: [PATCH] * morituri/common/task.py: Allow a SyncRunner to be constructed with verbose too. Separate a 'running' verbose mode from that. Fixes unwanted test output. * morituri/test/test_image_image.py: Run without verbosity. --- ChangeLog | 9 +++++++++ morituri/common/task.py | 16 +++++++++++----- morituri/test/test_image_image.py | 2 +- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 798d0e5..07e5ad4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-04-25 Thomas Vander Stichele + + * morituri/common/task.py: + Allow a SyncRunner to be constructed with verbose too. + Separate a 'running' verbose mode from that. + Fixes unwanted test output. + * morituri/test/test_image_image.py: + Run without verbosity. + 2009-04-25 Thomas Vander Stichele * morituri/test/test_image_image.py: diff --git a/morituri/common/task.py b/morituri/common/task.py index 5d909ac..0eb25ef 100644 --- a/morituri/common/task.py +++ b/morituri/common/task.py @@ -203,7 +203,7 @@ class MultiCombinedTask(BaseMultiTask): self.setProgress(float(self._stopped) / len(self.tasks)) BaseMultiTask.stopped(self, task) -class TaskRunner: +class TaskRunner(object): """ I am a base class for task runners. Task runners should be reusable. @@ -261,9 +261,14 @@ class SyncRunner(TaskRunner): """ I run the task synchronously in a gobject MainLoop. """ - def run(self, task, verbose=True, skip=False): - self._task = task + def __init__(self, verbose=True): self._verbose = verbose + + def run(self, task, verbose=None, skip=False): + self._task = task + self._verboseRun = self._verbose + if verbose is not None: + self._verboseRun = verbose self._skip = skip self._loop = gobject.MainLoop() @@ -280,7 +285,7 @@ class SyncRunner(TaskRunner): gobject.timeout_add(int(delta * 1000L), c) def progressed(self, task, value): - if not self._verbose: + if not self._verboseRun: return self._report() @@ -296,7 +301,8 @@ class SyncRunner(TaskRunner): sys.stdout.write("%s\r" % (' ' * len(text), )) def described(self, task, description): - self._report() + if self._verboseRun: + self._report() def stopped(self, task): self._loop.quit() diff --git a/morituri/test/test_image_image.py b/morituri/test/test_image_image.py index 7571147..71c6a9b 100644 --- a/morituri/test/test_image_image.py +++ b/morituri/test/test_image_image.py @@ -47,7 +47,7 @@ class TrackSeparateTestCase(unittest.TestCase): def setUp(self): self.image = image.Image(os.path.join(os.path.dirname(__file__), 'track-separate.cue')) - self.runner = task.SyncRunner() + self.runner = task.SyncRunner(verbose=False) self.image.setup(self.runner) def testAccurateRipChecksum(self):