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

fixe a bug when retrieving workflows

parent 3ab8b2fe
......@@ -46,17 +46,19 @@ class WorkflowsManager(object):
if not os.path.isdir(self.get_output_directory()):
os.makedirs(self.get_output_directory(), 0751)
self.dump_file = os.path.join(self.get_output_directory(), self.WORKFLOWS_DUMP_FILE_NAME)
# if the file already exists, load all the workflows dump path
if os.path.isfile(self.dump_file):
self.workflows_dump = pickle.load(open(self.dump_file))
else:
self.workflows_dump = {}
self.ids_file = os.path.join(self.get_output_directory(), self.IDS_FILE_NAME)
def _add_workflow(self, workflow):
WorkflowsManager.lock_workflows_file.acquire()
self.workflows_dump[utils.get_nb_string(workflow.id)] = workflow.dump_path
pickle.dump(self.workflows_dump, open(self.dump_file, "w"))
# first load the existing workflows
try:
workflows_dump = pickle.load(open(self.dump_file))
except:
workflows_dump = {}
# then add the new one
workflows_dump[utils.get_nb_string(workflow.id)] = workflow.dump_path
# and save them
pickle.dump(workflows_dump, open(self.dump_file, "w"))
WorkflowsManager.lock_workflows_file.release()
def get_available_workflows(self, parameters_section="parameters"):
......@@ -93,9 +95,13 @@ class WorkflowsManager(object):
def get_workflows(self):
workflows = []
for workflow_id in self.workflows_dump:
try:
workflows_dump = pickle.load(open(self.dump_file))
except:
workflows_dump = {}
for workflow_id in workflows_dump:
try:
workflow_dump = open(self.workflows_dump[workflow_id], "rb")
workflow_dump = open(workflows_dump[workflow_id], "rb")
workflows.append(pickle.load(workflow_dump))
workflow_dump.close()
except: pass
......@@ -113,8 +119,12 @@ class WorkflowsManager(object):
def get_workflow(self, workflow_id):
rworkflow_id = utils.get_nb_string(workflow_id)
if self.workflows_dump.has_key(rworkflow_id):
workflow_dump = open(self.workflows_dump[rworkflow_id], "rb")
try:
workflows_dump = pickle.load(open(self.dump_file))
except:
workflows_dump = {}
if workflows_dump.has_key(rworkflow_id):
workflow_dump = open(workflows_dump[rworkflow_id], "rb")
workflow = pickle.load(workflow_dump)
workflow_dump.close()
else:
......
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