Commit 9040e9d1 authored by Jerome Mariette's avatar Jerome Mariette
Browse files

use try and catch instead of sys.exit

parent 968f256a
......@@ -135,11 +135,20 @@ if __name__ == '__main__':
elif args["cmd_object"] == "rerun":
wfmanager.rerun_workflow(args["workflow_id"])
elif args["cmd_object"] == "reset":
wfmanager.reset_workflow_component(args["workflow_id"], args["component_name"])
try:
wfmanager.reset_workflow_component(args["workflow_id"], args["component_name"])
except Exception as e:
utils.display_error_message(str(e))
elif args["cmd_object"] == "delete":
wfmanager.delete_workflow(args["workflow_id"])
try:
wfmanager.delete_workflow(args["workflow_id"])
except Exception as e:
utils.display_error_message(str(e))
elif args["cmd_object"] == "execution_graph":
workflow = wfmanager.get_workflow(args["workflow_id"])
try:
workflow = wfmanager.get_workflow(args["workflow_id"])
except Exception as e:
utils.display_error_message(str(e))
gr = workflow.get_execution_graph()
inputs, components = [], []
for node in gr.nodes():
......@@ -155,10 +164,16 @@ if __name__ == '__main__':
elif args["cmd_object"] == "status":
if args["workflow_id"]:
workflow = wfmanager.get_workflow(args["workflow_id"])
try:
workflow = wfmanager.get_workflow(args["workflow_id"])
except Exception as e:
utils.display_error_message(str(e))
print Workflow.get_status_under_text_format(workflow, True, args["display_errors"])
else:
workflows = wfmanager.get_workflows(use_cache=True)
try:
workflows = wfmanager.get_workflows(use_cache=True)
except Exception as e:
utils.display_error_message(str(e))
if len(workflows) > 0:
workflows_by_id, wfids = {}, []
# first sort workflow by ID
......
......@@ -842,7 +842,7 @@ class Workflow(threading.Thread):
cpt.reset()
found = True
if not found:
raise Exception("Impossible to reset component '" + component_name + "'! This one is not part of the workflow")
raise Exception("Impossible to reset component '" + component_name + "'! This one is not part of the workflow!")
self.reseted_components.append(component_name)
self.status = self.STATUS_RESETED
self._serialize()
......
......@@ -24,6 +24,7 @@ import imp
import os
import pickle
import threading
import logging
import jflow.utils as utils
from jflow.config_reader import JFlowConfigReader
......@@ -128,7 +129,7 @@ class WorkflowsManager(object):
workflow_dump.close()
except:
logging.getLogger("jflow").debug("Workflow #" + rworkflow_id + " connot be retrieved in the available workflows!")
utils.display_error_message("Workflow #" + rworkflow_id + " connot be retrieved in the available workflows!")
raise Exception("Workflow #" + rworkflow_id + " connot be retrieved in the available workflows!")
# and save them
pickle.dump(workflows_dump, open(self.dump_file, "w"))
WorkflowsManager.lock_workflows_file.release()
......@@ -189,7 +190,7 @@ class WorkflowsManager(object):
workflow_dump.close()
else:
logging.getLogger("jflow").debug("Workflow #" + str(rworkflow_id) + " connot be retrieved in the available workflows!")
utils.display_error_message("Workflow #" + str(rworkflow_id) + " connot be retrieved in the available workflows!")
raise Exception("Workflow #" + str(rworkflow_id) + " connot be retrieved in the available workflows!")
return workflow
def get_workflow_directory(self, wname, wid):
......
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