make a LogStub class
This commit is contained in:
60
morituri/extern/task/task.py
vendored
60
morituri/extern/task/task.py
vendored
@@ -1,4 +1,4 @@
|
|||||||
# -*- Mode: Python; test-case-name: test_task -*-
|
# -*- Mode: Python -*-
|
||||||
# vi:si:et:sw=4:sts=4:ts=4
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
|
|
||||||
# Morituri - for those about to RIP
|
# Morituri - for those about to RIP
|
||||||
@@ -64,8 +64,29 @@ def _getExceptionMessage(exception, frame=-1, filename=None):
|
|||||||
% locals()
|
% locals()
|
||||||
|
|
||||||
|
|
||||||
|
class LogStub(object):
|
||||||
|
"""
|
||||||
|
I am a stub for a log interface.
|
||||||
|
"""
|
||||||
|
|
||||||
class Task(object):
|
### log stubs
|
||||||
|
def log(self, message, *args):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def debug(self, message, *args):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def info(self, message, *args):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def warning(self, message, *args):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def error(self, message, *args):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Task(LogStub):
|
||||||
"""
|
"""
|
||||||
I wrap a task in an asynchronous interface.
|
I wrap a task in an asynchronous interface.
|
||||||
I can be listened to for starting, stopping, description changes
|
I can be listened to for starting, stopping, description changes
|
||||||
@@ -94,22 +115,6 @@ class Task(object):
|
|||||||
_listeners = None
|
_listeners = None
|
||||||
|
|
||||||
|
|
||||||
### log stubs
|
|
||||||
def warning(self, message, *args):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def info(self, message, *args):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def debug(self, message, *args):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def log(self, message, *args):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def error(self, message, *args):
|
|
||||||
pass
|
|
||||||
|
|
||||||
### subclass methods
|
### subclass methods
|
||||||
def start(self, runner):
|
def start(self, runner):
|
||||||
"""
|
"""
|
||||||
@@ -421,30 +426,13 @@ class MultiCombinedTask(BaseMultiTask):
|
|||||||
self.setProgress(float(self._stopped) / len(self.tasks))
|
self.setProgress(float(self._stopped) / len(self.tasks))
|
||||||
BaseMultiTask.stopped(self, task)
|
BaseMultiTask.stopped(self, task)
|
||||||
|
|
||||||
class TaskRunner(object):
|
class TaskRunner(LogStub):
|
||||||
"""
|
"""
|
||||||
I am a base class for task runners.
|
I am a base class for task runners.
|
||||||
Task runners should be reusable.
|
Task runners should be reusable.
|
||||||
"""
|
"""
|
||||||
logCategory = 'TaskRunner'
|
logCategory = 'TaskRunner'
|
||||||
|
|
||||||
### log stubs
|
|
||||||
def warning(self, message, *args):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def info(self, message, *args):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def debug(self, message, *args):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def log(self, message, *args):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def error(self, message, *args):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def run(self, task):
|
def run(self, task):
|
||||||
"""
|
"""
|
||||||
Run the given task.
|
Run the given task.
|
||||||
|
|||||||
Reference in New Issue
Block a user