diff --git a/tools/data_source/data_source.py b/tools/data_source/data_source.py index f94b8847dd5..f97538074bf 100644 --- a/tools/data_source/data_source.py +++ b/tools/data_source/data_source.py @@ -24,11 +24,6 @@ GALAXY_ROOT_DIR = os.path.realpath(os.path.join(os.path.dirname(__file__), os.pa GALAXY_DATATYPES_CONF_FILE = os.path.join(GALAXY_ROOT_DIR, "datatypes_conf.xml") -def stop_err(msg): - sys.stderr.write(msg) - sys.exit() - - def __main__(): if len(sys.argv) >= 3: max_file_size = int(sys.argv[2]) @@ -54,7 +49,7 @@ def __main__(): cur_URL = params['param_dict'].get("%s|%s|URL" % (GALAXY_PARAM_PREFIX, data_dict["out_data_name"]), URL) if not cur_URL or urlparse(cur_URL).scheme not in ("http", "https", "ftp"): open(cur_filename, "w").write("") - stop_err("The remote data source application has not sent back a URL parameter in the request.") + sys.exit("The remote data source application has not sent back a URL parameter in the request.") # The following calls to urlopen() will use the above default timeout try: @@ -63,11 +58,11 @@ def __main__(): elif URL_method == "post": page = urlopen(cur_URL, urlencode(params["param_dict"]).encode("utf-8"), timeout=DEFAULT_SOCKET_TIMEOUT) except Exception as e: - stop_err("The remote data source application may be off line, please try again later. Error: %s" % str(e)) + sys.exit("The remote data source application may be off line, please try again later. Error: %s" % str(e)) if max_file_size: file_size = int(page.info().get("Content-Length", 0)) if file_size > max_file_size: - stop_err( + sys.exit( "The size of the data (%d bytes) you have requested exceeds the maximum allowed (%d bytes) on this server." % (file_size, max_file_size) ) @@ -79,13 +74,13 @@ def __main__(): source_encoding=get_charset_from_http_headers(page.headers), ) except Exception as e: - stop_err("Unable to fetch %s:\n%s" % (cur_URL, e)) + sys.exit("Unable to fetch %s:\n%s" % (cur_URL, e)) # here import checks that upload tool performs try: ext = sniff.handle_uploaded_dataset_file(cur_filename, datatypes_registry, ext=data_dict["ext"]) except Exception as e: - stop_err(str(e)) + sys.exit(str(e)) info = dict(type="dataset", dataset_id=data_dict["dataset_id"], ext=ext) with open(params["job_config"]["TOOL_PROVIDED_JOB_METADATA_FILE"], "w") as json_file: