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

from python2 to python3 > ok from command line

parent 9474bb02
......@@ -41,7 +41,7 @@ class WorkflowsManager(object):
def __init__(self):
self.config_reader = JFlowConfigReader()
if not os.path.isdir(self.get_output_directory()):
os.makedirs(self.get_output_directory(), 0751)
os.makedirs(self.get_output_directory(), 0o751)
self.dump_file = os.path.join(self.get_output_directory(), self.WORKFLOWS_DUMP_FILE_NAME)
self.ids_file = os.path.join(self.get_output_directory(), self.IDS_FILE_NAME)
......@@ -49,7 +49,7 @@ class WorkflowsManager(object):
WorkflowsManager.lock_workflows_file.acquire()
# first load the existing workflows
try:
wdfh = open(self.dump_file)
wdfh = open(self.dump_file, "rb")
workflows_dump = pickle.load(wdfh)
wdfh.close()
except:
......@@ -59,7 +59,7 @@ class WorkflowsManager(object):
workflows_dump[utils.get_nb_string(workflow.id)] = {"dump_path": workflow.dump_path,
"object": workflow.minimize()}
# and save them
wdfh = open(self.dump_file, "w")
wdfh = open(self.dump_file, "wb")
pickle.dump(workflows_dump, wdfh)
wdfh.close()
WorkflowsManager.lock_workflows_file.release()
......@@ -78,13 +78,14 @@ class WorkflowsManager(object):
if issubclass(obj, jflow.workflow.Workflow) and obj.__name__ != jflow.workflow.Workflow.__name__:
for function in functions:
# check if the workflow has the requested methode
for ifunction in inspect.getmembers(obj, predicate=inspect.ismethod):
# inspect.ismethod has been changed for inspect.isfunction in Python3
for ifunction in inspect.getmembers(obj, predicate=inspect.isfunction):
if ifunction[0] == function:
# try to build the workflow
try:
wf_instances.append(obj(function=function))
wf_methodes.append(function)
except: pass
#try:
wf_instances.append(obj(function=function))
wf_methodes.append(function)
#except: pass
return [wf_instances, wf_methodes]
def rerun_workflow(self, workflow_id):
......@@ -119,7 +120,7 @@ class WorkflowsManager(object):
from jflow.workflow import Workflow
WorkflowsManager.lock_workflows_file.acquire()
try:
awfh = open(self.dump_file)
awfh = open(self.dump_file, "rb")
all_workflows_dump = pickle.load(awfh)
awfh.close()
except:
......@@ -137,7 +138,7 @@ class WorkflowsManager(object):
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!")
# and save them
awfh = open(self.dump_file, "w")
awfh = open(self.dump_file, "wb")
pickle.dump(all_workflows_dump, awfh)
awfh.close()
WorkflowsManager.lock_workflows_file.release()
......@@ -157,7 +158,7 @@ class WorkflowsManager(object):
from jflow.workflow import Workflow
workflows = []
try:
awfh = open(self.dump_file)
awfh = open(self.dump_file, "rb")
workflows_dump = pickle.load(awfh)
awfh.close()
except:
......@@ -191,12 +192,12 @@ class WorkflowsManager(object):
def get_workflow(self, workflow_id):
rworkflow_id = utils.get_nb_string(workflow_id)
try:
wdfh = open(self.dump_file)
wdfh = open(self.dump_file, "rb")
workflows_dump = pickle.load(wdfh)
wdfh.close()
except:
workflows_dump = {}
if workflows_dump.has_key(rworkflow_id):
if rworkflow_id in workflows_dump:
workflow_dump = open(workflows_dump[rworkflow_id]["dump_path"], "rb")
workflow = pickle.load(workflow_dump)
workflow_dump.close()
......
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