Skip to content

Commit

Permalink
Make upload tool python3 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdbeek authored and nsoranzo committed Jul 16, 2018
1 parent 9f352f7 commit 66af9ce
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,6 @@ vine==1.1.4
warlock==1.2.0
wcwidth==0.1.7; sys_platform != 'win32'
webencodings==0.5.1
webob==1.4.2
webob==1.8.2
whoosh==2.7.4
wrapt==1.10.11
2 changes: 1 addition & 1 deletion lib/galaxy/tools/actions/upload_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def _chown(path):
if link_data_only == 'copy_files' and trans.app.config.external_chown_script:
_chown(uploaded_dataset.path)
tool_params.append(params)
with tempfile.NamedTemporaryFile(prefix='upload_params_', delete=False) as fh:
with tempfile.NamedTemporaryFile(mode="w", prefix='upload_params_', delete=False) as fh:
json_file_path = fh.name
dump(tool_params, fh)
return json_file_path
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/tools/parameters/dynamic_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ def load_from_parameter(from_parameter, transform_lines=None):
for field in from_parameter.split('.'):
obj = getattr(obj, field)
if transform_lines:
obj = eval(transform_lines)
obj = eval(transform_lines, globals(), locals())
return self.parse_file_fields(obj)
self.tool_param = tool_param
self.columns = {}
Expand Down
4 changes: 2 additions & 2 deletions lib/galaxy/web/framework/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import types

import routes
import webob
import webob.exc
# We will use some very basic HTTP/wsgi utilities from the paste library
from paste import httpexceptions
from paste.request import get_cookies
Expand Down Expand Up @@ -459,7 +459,7 @@ def wsgi_status(self):
Return status line in format appropriate for WSGI `start_response`
"""
if isinstance(self.status, int):
exception = httpexceptions.get_exception(self.status)
exception = webob.exc.status_map.get(self.status)
return "%d %s" % (exception.code, exception.title)
else:
return self.status
Expand Down
13 changes: 8 additions & 5 deletions tools/data_source/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@

from six.moves.urllib.request import urlopen

from galaxy import util
from galaxy.datatypes import sniff
from galaxy.datatypes.registry import Registry
from galaxy.datatypes.upload_util import handle_upload, UploadProblemException
from galaxy.util import (
bunch,
unicodify
)

assert sys.version_info[:2] >= (2, 7)

Expand All @@ -36,9 +39,9 @@ def file_err(msg, dataset):


def safe_dict(d):
"""Recursively clone json structure with UTF-8 dictionary keys."""
"""Recursively clone JSON structure with unicode dictionary keys."""
if isinstance(d, dict):
return dict([(k.encode('utf-8'), safe_dict(v)) for k, v in d.items()])
return dict([(unicodify(k), safe_dict(v)) for k, v in d.items()])
elif isinstance(d, list):
return [safe_dict(x) for x in d]
else:
Expand Down Expand Up @@ -172,7 +175,7 @@ def add_composite_file(dataset, output_path, files_path):
if dataset.composite_files:
os.mkdir(files_path)
for name, value in dataset.composite_files.items():
value = util.bunch.Bunch(**value)
value = bunch.Bunch(**value)
if dataset.composite_file_paths[value.name] is None and not value.optional:
raise UploadProblemException('A required composite data file was not provided (%s)' % name)
elif dataset.composite_file_paths[value.name] is not None:
Expand Down Expand Up @@ -251,7 +254,7 @@ def __main__():

metadata = []
for dataset in datasets:
dataset = util.bunch.Bunch(**safe_dict(dataset))
dataset = bunch.Bunch(**safe_dict(dataset))
try:
output_path = output_paths[int(dataset.dataset_id)][0]
except Exception:
Expand Down

0 comments on commit 66af9ce

Please sign in to comment.