Commit 42773f31 authored by Gerald Salin's avatar Gerald Salin
Browse files

add some logging

parent fc4ad216
......@@ -507,8 +507,11 @@ class Workflow(threading.Thread):
return gr
def delete(self):
logging.getLogger("wf." + str(self.id)).debug("delete. Trying to delete " + self.directory)
if self.get_status() in [self.STATUS_COMPLETED, self.STATUS_FAILED, self.STATUS_ABORTED]:
utils.robust_rmtree(self.directory)
logging.getLogger("wf." + str(self.id)).debug("status is OK for deletetion" )
#utils.robust_rmtree(self.directory)
logging.getLogger("wf." + str(self.id)).debug("workflow deleted" )
@staticmethod
def config_parser(arg_lines):
......
......@@ -124,6 +124,7 @@ class WorkflowsManager(object):
def delete_workflow(self, workflow_id):
from jflow.workflow import Workflow
def delete_func():
try:
awfh = open(self.dump_file, "rb")
......@@ -133,16 +134,23 @@ class WorkflowsManager(object):
all_workflows_dump = {}
rworkflow_id = utils.get_nb_string(workflow_id)
try:
logging.getLogger("WorkflowsManager").debug("Enumerates workflows in " + self.dump_file)
for s in all_workflows_dump:
logging.getLogger("WorkflowsManager").debug("Enumerate #" + all_workflows_dump[s]["dump_path"])
logging.getLogger("WorkflowsManager").debug("Trying to load dump of Workflow #" + rworkflow_id + " !")
workflow_dump = open(all_workflows_dump[rworkflow_id]["dump_path"], "rb")
workflow = pickle.load(workflow_dump)
workflow_dump.close()
logging.getLogger("WorkflowsManager").debug("Dump of Workflow #" + rworkflow_id + " loaded!")
# if workflow is not in a running status
if workflow.get_status() in [Workflow.STATUS_COMPLETED, Workflow.STATUS_FAILED, Workflow.STATUS_ABORTED]:
logging.getLogger("WorkflowsManager").debug("Trying to delete Workflow #" + rworkflow_id + "!")
workflow.delete()
del all_workflows_dump[rworkflow_id]
logging.getLogger("WorkflowsManager").debug("Workflow #" + rworkflow_id + " is deleted!")
del all_workflows_dump[rworkflow_id]
except:
logging.getLogger("jflow").debug("Workflow #" + rworkflow_id + " connot be retrieved in the available workflows!")
raise Exception("Workflow #" + rworkflow_id + " connot be retrieved in the available workflows!")
logging.getLogger("WorkflowsManager").debug("Workflow #" + rworkflow_id + " cannot be retrieved in the available workflows!")
raise Exception("Workflow #" + rworkflow_id + " cannot be retrieved in the available workflows!")
# and save them
awfh = open(self.dump_file, "wb")
pickle.dump(all_workflows_dump, awfh)
......@@ -222,8 +230,8 @@ class WorkflowsManager(object):
workflow = pickle.load(workflow_dump)
workflow_dump.close()
else:
logging.getLogger("jflow").debug("Workflow #" + str(rworkflow_id) + " connot be retrieved in the available workflows!")
raise Exception("Workflow #" + str(rworkflow_id) + " connot be retrieved in the available workflows!")
logging.getLogger("jflow").debug("Workflow #" + str(rworkflow_id) + " cannot be retrieved in the available workflows!")
raise Exception("Workflow #" + str(rworkflow_id) + " cannot be retrieved in the available workflows!")
return workflow
def get_workflow_directory(self, wname, wid):
......
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