Commit 3d47cbc6 authored by Jerome Mariette's avatar Jerome Mariette
Browse files

from python2 to python3 > ok from command line

parent 24db606c
......@@ -28,14 +28,14 @@ import argparse
from argparse import ArgumentTypeError
from workflows_manager import WorkflowsManager
from config_reader import JFlowConfigReader
from workflow import Workflow
from parameter import browsefile, localfile, urlfile, inputfile, create_test_function, MiltipleAction, MiltipleAppendAction, MultipleParameters
from .workflows_manager import WorkflowsManager
from .config_reader import JFlowConfigReader
from .workflow import Workflow
from .parameter import browsefile, localfile, urlfile, inputfile, create_test_function, MiltipleAction, MiltipleAppendAction, MultipleParameters
from workflows.types import *
import utils
from . import utils
from cctools.util import time_format
from utils import get_octet_string_representation
from .utils import get_octet_string_representation
# function in charge to upload large files
class UploadFieldStorage(cgi.FieldStorage):
......@@ -131,7 +131,7 @@ class JFlowServer (object):
socket_opts = jflowconf.get_socket_options()
# add the result directory
if config is None or not config.has_key('/'):
if config is None or not '/' in config:
config['/'] = {'tools.staticdir.root': jflowconf.get_work_directory()}
else:
link = os.path.join(config['/']['tools.staticdir.root'], "data")
......@@ -161,7 +161,7 @@ class JFlowServer (object):
value = func(*args, **kw)
cherrypy.response.headers["Content-Type"] = "application/json"
# if JSONP request
if kw.has_key("callback"): return kw["callback"] + "(" + json.dumps(value, cls=JFlowJSONEncoder) + ")"
if "callback" in kw: return kw["callback"] + "(" + json.dumps(value, cls=JFlowJSONEncoder) + ")"
# else return the JSON
else: return json.dumps(value)
return wrapper
......@@ -279,7 +279,7 @@ class JFlowServer (object):
elif hash_param["sub_parameters"][-1]["format"] == '%y/%m/%d':
hash_param["sub_parameters"][-1]["format"] = 'yy/mm/dd'
parameters.append(hash_param)
if parameters_per_groups.has_key(param.group):
if param.group in parameters_per_groups:
parameters_per_groups[param.group].append(hash_param)
else: parameters_per_groups[param.group] = [hash_param]
groups.append(param.group)
......@@ -299,18 +299,18 @@ class JFlowServer (object):
# handle MultiParameterList
multi_sub_params = {}
for key in kwargs.keys():
for key in list(kwargs.keys()):
parts = key.split(JFlowServer.MULTIPLE_TYPE_SPLITER)
if len(parts) == 3:
if not kwargs_modified.has_key(parts[0]):
if not parts[0] in kwargs_modified:
kwargs_modified[parts[0]] = []
multi_sub_params[parts[0]] = {}
if multi_sub_params[parts[0]].has_key(parts[2]):
if parts[2] in multi_sub_params[parts[0]]:
multi_sub_params[parts[0]][parts[2]].append((parts[1], kwargs[key].encode('utf8')))
else:
multi_sub_params[parts[0]][parts[2]] = [(parts[1], kwargs[key].encode('utf8'))]
for key in kwargs.keys():
for key in list(kwargs.keys()):
parts = key.split(JFlowServer.MULTIPLE_TYPE_SPLITER)
# split append values
new_values = kwargs[key].encode('utf8').split(JFlowServer.APPEND_PARAM_SPLITER)
......@@ -321,7 +321,7 @@ class JFlowServer (object):
kwargs_modified[key] = new_values
# if this is a MultiParameter
elif len(parts) == 2:
if kwargs_modified.has_key(parts[0]):
if parts[0] in kwargs_modified:
kwargs_modified[parts[0]].append((parts[1], new_values))
else:
kwargs_modified[parts[0]] = [(parts[1], new_values)]
......@@ -357,7 +357,7 @@ class JFlowServer (object):
@cherrypy.expose
def upload_light(self, **kwargs):
uniq_directory = ""
for key in kwargs.keys():
for key in list(kwargs.keys()):
if key == "uniq_directory":
uniq_directory = kwargs['uniq_directory']
else:
......@@ -399,7 +399,7 @@ class JFlowServer (object):
# convert the header keys to lower case
lcHDRS = {}
for key, val in cherrypy.request.headers.iteritems():
for key, val in cherrypy.request.headers.items():
lcHDRS[key.lower()] = val
# at this point we could limit the upload on content-length...
......@@ -416,7 +416,7 @@ class JFlowServer (object):
# filename; if we renamed, there would be a failure because
# the NamedTemporaryFile, used by our version of cgi.FieldStorage,
# explicitly deletes the original filename
for current in formFields.keys():
for current in list(formFields.keys()):
if current != 'uniq_directory':
currentFile = formFields[current]
fileDir = os.path.join(self.jflow_config_reader.get_tmp_directory(), formFields.getvalue("uniq_directory"))
......@@ -439,7 +439,7 @@ class JFlowServer (object):
status = []
workflows = self.wfmanager.get_workflows(use_cache=True)
for workflow in workflows:
if kwargs.has_key("metadata_filter"):
if "metadata_filter" in kwargs:
is_ok = False
for wf_meta in workflow.metadata:
for metadata in kwargs["metadata_filter"].split(","):
......@@ -489,7 +489,7 @@ class JFlowServer (object):
@jsonify
def get_workflow_outputs(self, **kwargs):
on_disk_outputs, on_web_outputs = self.wfmanager.get_workflow_outputs(kwargs["workflow_id"]), {}
for cpt_name in on_disk_outputs.keys():
for cpt_name in list(on_disk_outputs.keys()):
on_web_outputs[cpt_name] = {}
for outf in on_disk_outputs[cpt_name]:
on_web_outputs[cpt_name][outf] = self._webify_outputs(JFlowServer.JFLOW_WDATA, on_disk_outputs[cpt_name][outf])
......@@ -500,7 +500,7 @@ class JFlowServer (object):
def validate_field(self, **kwargs):
try:
value_key = None
for key in kwargs.keys():
for key in list(kwargs.keys()):
if key != "type" and key != "callback" and key != "_" and key != "action":
value_key = key
break
......@@ -511,5 +511,5 @@ class JFlowServer (object):
else:
create_test_function(kwargs["type"])(kwargs[value_key].encode('utf8'))
return True
except Exception, e:
except Exception as e:
return str(e)
\ No newline at end of file
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