diff --git a/lib/galaxy/jobs/__init__.py b/lib/galaxy/jobs/__init__.py index f485b52e88b..71dd60e7852 100644 --- a/lib/galaxy/jobs/__init__.py +++ b/lib/galaxy/jobs/__init__.py @@ -1939,7 +1939,7 @@ class JobWrapper(HasResourceParameters): self.output_paths = [t[2] for t in results] self.output_hdas_and_paths = dict([(t[0], t[1:]) for t in results]) if special: - false_path = dataset_path_rewriter.rewrite_dataset_path(special.dataset, 'output') + false_path = dataset_path_rewriter.rewrite_dataset_path(special, 'output') dsp = DatasetPath(special.dataset.id, special.dataset.file_name, false_path) self.output_paths.append(dsp) return self.output_paths diff --git a/lib/galaxy/tools/imp_exp/imp_history_from_archive.xml b/lib/galaxy/tools/imp_exp/imp_history_from_archive.xml index 94e165c7d5a..c749b6115f6 100644 --- a/lib/galaxy/tools/imp_exp/imp_history_from_archive.xml +++ b/lib/galaxy/tools/imp_exp/imp_history_from_archive.xml @@ -1,6 +1,9 @@ - + + + requests + #from base64 import b64encode# python '$__tool_directory__/unpack_tar_gz_archive.py' '${ b64encode(str($__ARCHIVE_SOURCE__).encode('utf-8')).decode('utf-8')}' diff --git a/lib/galaxy/tools/imp_exp/unpack_tar_gz_archive.py b/lib/galaxy/tools/imp_exp/unpack_tar_gz_archive.py index f1a8d1daf4b..f3fad868169 100644 --- a/lib/galaxy/tools/imp_exp/unpack_tar_gz_archive.py +++ b/lib/galaxy/tools/imp_exp/unpack_tar_gz_archive.py @@ -10,7 +10,6 @@ from __future__ import print_function import math import optparse import os -import sys import tarfile import tempfile from base64 import b64decode @@ -26,22 +25,18 @@ def url_to_file(url, dest_file): """ Transfer a file from a remote URL to a temporary file. """ - try: - url_reader = requests.get(url, stream=True) - CHUNK = 10 * 1024 # 10k - total = 0 - fp = open(dest_file, 'wb') + url_reader = requests.get(url, stream=True) + assert url_reader.ok, "History import failed, server returned '%s'" % url_reader.reason + CHUNK = 10 * 1024 # 10k + total = 0 + with open(dest_file, 'wb') as fp: for chunk in url_reader.iter_content(chunk_size=CHUNK): if chunk: fp.write(chunk) total += CHUNK if total > MAX_SIZE: break - fp.close() - return dest_file - except Exception as e: - print("Exception getting file from URL: %s" % e, file=sys.stderr) - return None + return dest_file def check_archive(archive_file, dest_dir): @@ -96,7 +91,4 @@ if __name__ == "__main__": parser.add_option('-F', '--file', dest='is_file', action="store_true", help='Source is a file.') parser.add_option('-e', '--encoded', dest='is_b64encoded', action="store_true", default=False, help='Source and destination dir values are base64 encoded.') (options, args) = parser.parse_args() - try: - main(options, args) - except Exception as e: - print("Error unpacking tar/gz archive: %s" % e, file=sys.stderr) + main(options, args) diff --git a/lib/galaxy/web/framework/webapp.py b/lib/galaxy/web/framework/webapp.py index 273eb40cc69..d77b230a275 100644 --- a/lib/galaxy/web/framework/webapp.py +++ b/lib/galaxy/web/framework/webapp.py @@ -106,6 +106,7 @@ class WebApplication(base.WebApplication): if isinstance(e, MessageException): # In the case of a controller exception, sanitize to make sure # unsafe html input isn't reflected back to the user + trans.response.status = e.status_code return trans.show_message(sanitize_html(e.err_msg), e.type) def make_body_iterable(self, trans, body):