Commit c2a9cd3f authored by Jerome Mariette's avatar Jerome Mariette
Browse files

allow to run other function than process

parent 9047b9e1
......@@ -72,6 +72,7 @@ class Workflow(threading.Thread):
self.status = self.STATUS_STARTED
self.start_time = None
self.end_time = None
self.function = "process"
self.comp_pckg = self._import_components()
self.engine_arguments = ''
self.component_nameids_is_init = False
......@@ -187,7 +188,7 @@ class Workflow(threading.Thread):
# if not done yet, init the component nameids list before to run
if not self.component_nameids_is_init:
try:
self.process()
getattr(self, self.function)()
except SystemExit, e:
self.status = self.STATUS_FAILED
self.end_time = time.time()
......@@ -196,7 +197,7 @@ class Workflow(threading.Thread):
self.component_nameids_is_init = True
self._serialize()
try:
self.process()
getattr(self, self.function)()
except SystemExit, e:
self.status = self.STATUS_FAILED
self.end_time = time.time()
......
......@@ -58,17 +58,19 @@ class WorkflowsManager(object):
except: pass
return wf_instances
def rerun_workflow(self, workflow_id):
def rerun_workflow(self, workflow_id, function="process"):
workflow = self.get_workflow(workflow_id)
workflow.function = function
workflow.start()
def run_workflow(self, workflow_class, args):
def run_workflow(self, workflow_class, args, function="process"):
# Load all modules within the workflow module
for importer, modname, ispkg in pkgutil.iter_modules(workflows.__path__, workflows.__name__ + "."):
__import__(modname)
# Search for Workflow classes
for class_name, obj in inspect.getmembers(sys.modules[modname], inspect.isclass):
if class_name == workflow_class: workflow = obj(args, id=self.get_next_id())
workflow.function = function
workflow.start()
return workflow
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment