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): ...@@ -72,6 +72,7 @@ class Workflow(threading.Thread):
self.status = self.STATUS_STARTED self.status = self.STATUS_STARTED
self.start_time = None self.start_time = None
self.end_time = None self.end_time = None
self.function = "process"
self.comp_pckg = self._import_components() self.comp_pckg = self._import_components()
self.engine_arguments = '' self.engine_arguments = ''
self.component_nameids_is_init = False self.component_nameids_is_init = False
...@@ -187,7 +188,7 @@ class Workflow(threading.Thread): ...@@ -187,7 +188,7 @@ class Workflow(threading.Thread):
# if not done yet, init the component nameids list before to run # if not done yet, init the component nameids list before to run
if not self.component_nameids_is_init: if not self.component_nameids_is_init:
try: try:
self.process() getattr(self, self.function)()
except SystemExit, e: except SystemExit, e:
self.status = self.STATUS_FAILED self.status = self.STATUS_FAILED
self.end_time = time.time() self.end_time = time.time()
...@@ -196,7 +197,7 @@ class Workflow(threading.Thread): ...@@ -196,7 +197,7 @@ class Workflow(threading.Thread):
self.component_nameids_is_init = True self.component_nameids_is_init = True
self._serialize() self._serialize()
try: try:
self.process() getattr(self, self.function)()
except SystemExit, e: except SystemExit, e:
self.status = self.STATUS_FAILED self.status = self.STATUS_FAILED
self.end_time = time.time() self.end_time = time.time()
......
...@@ -58,17 +58,19 @@ class WorkflowsManager(object): ...@@ -58,17 +58,19 @@ class WorkflowsManager(object):
except: pass except: pass
return wf_instances return wf_instances
def rerun_workflow(self, workflow_id): def rerun_workflow(self, workflow_id, function="process"):
workflow = self.get_workflow(workflow_id) workflow = self.get_workflow(workflow_id)
workflow.function = function
workflow.start() 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 # Load all modules within the workflow module
for importer, modname, ispkg in pkgutil.iter_modules(workflows.__path__, workflows.__name__ + "."): for importer, modname, ispkg in pkgutil.iter_modules(workflows.__path__, workflows.__name__ + "."):
__import__(modname) __import__(modname)
# Search for Workflow classes # Search for Workflow classes
for class_name, obj in inspect.getmembers(sys.modules[modname], inspect.isclass): 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()) if class_name == workflow_class: workflow = obj(args, id=self.get_next_id())
workflow.function = function
workflow.start() workflow.start()
return workflow return workflow
......
Supports Markdown
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