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