# A Task is a function that runs within the context of its run() function that runs the function execute(), which does several things, reporting back to the caller as it goes with the use of yield
# the done() method ought to return true if the task has run in the past
# the execute() method must implement the configuration act itself
# run() wraps the output of execute() within a Starting taskname and a Completed taskname message
# tasks have a name
classTaskFailed(Exception): pass
#def __init__(self,code,msg):
#Exception.__init__(self,msg)
#self.code = code
classConfigTask:
name="generic config task"
autoMode=False
def__init__(self): pass
defdone(self):
"""Returns true if the config task has already been done in the past, false if it hasn't"""
returnFalse
defexecute(self):
"""Executes the configuration task. Must not be run if test() returned true.
Must yield strings that describe the steps in the task.
Raises TaskFailed if the task failed at some step.
"""
defrun (self):
stderr("Starting %s"%self.name)
it=self.execute()
ifnotit:
pass# not a yielding iterable
else:
formsginit: stderr(msg)
stderr("Completed %s"%self.name)
defsetAutoMode(self, autoMode):
self.autoMode=autoMode
defisAutoMode(self):
returnself.autoMode
# ============== these are some configuration tasks ==================