From d1bc98dfcb617cf022070b96ee74f437cfe5c207 Mon Sep 17 00:00:00 2001 From: Nicola Soranzo Date: Thu, 12 Oct 2017 17:10:12 +0100 Subject: [PATCH] Python3: fix remaining print statements Remove some debugging prints. Fix import order. Consolidate exception logging in ToolShed database migrations. --- .ci/flake8_lint_include_list.txt | 3 + .ci/py3_sources.txt | 1 + contrib/galaxy_config_merger.py | 3 - .../converters/bed_to_gff_converter.py | 2 +- .../converters/gff_to_bed_converter.py | 2 +- .../converters/interval_to_bed_converter.py | 2 +- .../interval_to_bedstrict_converter.py | 2 +- .../converters/maf_to_fasta_converter.py | 2 +- .../converters/maf_to_interval_converter.py | 2 +- .../picard_interval_list_to_bed6_converter.py | 2 +- lib/galaxy/datatypes/dataproviders/base.py | 2 - lib/galaxy/model/__init__.py | 1 - lib/galaxy/model/search.py | 3 - lib/galaxy/objectstore/s3.py | 33 ++++----- lib/galaxy/tools/deps/containers.py | 10 ++- lib/galaxy/tools/imp_exp/__init__.py | 2 - lib/galaxy/tools/parameters/__init__.py | 12 +-- .../tools/parameters/input_translation.py | 4 +- lib/galaxy/tools/util/maf_utilities.py | 2 +- lib/galaxy/util/jstree.py | 19 +++-- .../visualization/data_providers/basic.py | 1 - lib/galaxy/web/form_builder.py | 35 +++++---- .../webapps/reports/controllers/tools.py | 14 ++-- .../migrate/versions/0001_initial_tables.py | 4 +- .../versions/0002_add_tool_suite_column.py | 14 ++-- ...03_review_and_review_association_tables.py | 12 +-- .../versions/0004_repository_tables.py | 28 +++---- .../versions/0005_drop_tool_related_tables.py | 60 +++++++-------- .../versions/0006_add_email_alerts_column.py | 14 ++-- ...ng_description_times_downloaded_columns.py | 24 +++--- .../0008_add_repository_metadata_table.py | 14 ++-- .../versions/0009_add_malicious_column.py | 14 ++-- .../0010_add_new_repo_alert_column.py | 14 ++-- .../versions/0011_add_tool_versions_column.py | 12 +-- .../versions/0012_add_downloadable_column.py | 12 +-- .../versions/0013_add_review_tables.py | 34 ++++----- .../versions/0014_add_deprecated_column.py | 14 ++-- .../versions/0015_add_api_keys_table.py | 12 +-- ...ols_functionally_correct_errors_columns.py | 44 +++++------ ...ty_columns_to_repository_metadata_table.py | 44 +++++------ ...18_add_repository_metadata_flag_columns.py | 28 +++---- ...est_table_and_test_install_error_column.py | 20 ++--- .../0020_add_repository_type_column.py | 12 +-- .../0021_change_repository_type_value.py | 4 +- .../0022_add_repository_admin_roles.py | 13 ++-- ...023_add_repository_url_and_hompeage_url.py | 12 +-- .../migrate/versions/0024_password_reset.py | 10 +-- .../migrate/versions/0025_session_timeout.py | 10 +-- .../tool_dependencies/recipe/step_handler.py | 2 +- scripts/api/copy_hda_to_library_folder.py | 6 +- scripts/api/library_upload_dir.py | 8 +- scripts/api/workflow_import.py | 1 - .../admin_cleanup_datasets.py | 2 +- scripts/cleanup_datasets/cleanup_datasets.py | 2 +- scripts/cleanup_datasets/populate_uuid.py | 2 +- .../remove_renamed_datasets_from_disk.py | 2 +- .../rename_purged_datasets.py | 2 +- .../cleanup_datasets/update_dataset_size.py | 2 +- scripts/cleanup_datasets/update_metadata.py | 2 +- scripts/db_shell.py | 2 +- scripts/extract_toolbox_sections.py | 5 +- scripts/get_platforms.py | 6 +- scripts/helper.py | 10 ++- scripts/loc_files/create_all_fasta_loc.py | 18 +++-- scripts/manage_tools.py | 4 +- scripts/metagenomics/convert_title.py | 12 +-- scripts/microbes/BeautifulSoup.py | 3 +- scripts/microbes/create_bacteria_loc_file.py | 21 +++--- scripts/microbes/create_bacteria_table.py | 9 ++- scripts/microbes/create_nib_seq_loc_file.py | 12 +-- scripts/microbes/get_builds_lengths.py | 7 +- scripts/microbes/harvest_bacteria.py | 34 +++++---- scripts/microbes/ncbi_to_ucsc.py | 21 +++--- scripts/migrate_tools/migrate_tools.py | 4 +- scripts/others/incorrect_gops_jobs.py | 38 +++++----- scripts/others/incorrect_gops_join_jobs.py | 38 +++++----- scripts/set_dataset_sizes.py | 12 +-- scripts/set_user_disk_usage.py | 24 +++--- scripts/slideshow/build_slideshow.py | 4 +- .../api/add_repository_registry_entry.py | 7 +- scripts/tool_shed/api/common.py | 74 ++++++++++--------- scripts/tool_shed/api/create_categories.py | 3 +- scripts/tool_shed/api/create_users.py | 3 +- scripts/tool_shed/api/export.py | 9 ++- .../api/get_filtered_repository_revisions.py | 9 ++- .../api/remove_repository_registry_entry.py | 7 +- .../api/reset_metadata_on_repositories.py | 8 +- .../bootstrap_tool_shed/bootstrap_util.py | 8 +- .../create_user_with_api_key.py | 13 ++-- scripts/tool_shed/build_ts_whoosh_index.py | 11 +-- scripts/tool_shed/check_download_urls.py | 6 +- ...mpty_tool_dependency_installation_paths.py | 16 ++-- ...mpty_tool_dependency_installation_paths.py | 18 +++-- .../clean_up_tool_dependency_directory.py | 6 +- ...deprecate_repositories_without_metadata.py | 27 +++---- .../migrate_tools_to_repositories.py | 52 ++++++------- ...ol_dependency_installation_dir_contents.py | 10 ++- scripts/tools/maf/check_loc_file.py | 14 ++-- scripts/update_shed_config_path.py | 6 +- test/unit/managers/test_CollectionManager.py | 13 ---- .../managers/test_HistoryContentsManager.py | 13 ---- test/unit/managers/test_HistoryManager.py | 2 - test/unit/unittest_utils/galaxy_mock.py | 4 - .../plugins/test_VisualizationsRegistry.py | 1 - tools/data_source/fetch.py | 2 +- tools/data_source/genbank.py | 2 +- tools/data_source/import.py | 2 +- tools/data_source/microbial_import.py | 2 +- tools/filters/bed_to_gff_converter.py | 2 +- tools/filters/gtf_to_bedgraph_converter.py | 2 +- tools/filters/ucsc_gene_bed_to_exon_bed.py | 8 +- tools/filters/ucsc_gene_bed_to_exon_bed.xml | 2 +- tools/filters/ucsc_gene_bed_to_intron_bed.py | 2 +- tools/filters/ucsc_gene_table_to_intervals.py | 2 +- tools/metag_tools/shrimp_wrapper.py | 2 +- tools/sr_assembly/velvetg_wrapper.py | 2 +- 116 files changed, 679 insertions(+), 644 deletions(-) diff --git a/.ci/flake8_lint_include_list.txt b/.ci/flake8_lint_include_list.txt index 3e14bb58636..c94fe657dda 100644 --- a/.ci/flake8_lint_include_list.txt +++ b/.ci/flake8_lint_include_list.txt @@ -57,6 +57,7 @@ lib/galaxy/managers/taggable.py lib/galaxy/model/ lib/galaxy/objectstore/pulsar.py lib/galaxy/objectstore/s3_multipart_upload.py +lib/galaxy/objectstore/s3.py lib/galaxy/openid/__init__.py lib/galaxy/quota/ lib/galaxy/sample_tracking/data_transfer.py @@ -81,6 +82,7 @@ lib/galaxy/visualization/tracks/ lib/galaxy/web/base/ lib/galaxy/web/buildapp.py lib/galaxy/web/formatting.py +lib/galaxy/web/form_builder.py lib/galaxy/web/framework/base.py lib/galaxy/web/framework/decorators.py lib/galaxy/web/framework/helpers/grids.py @@ -126,6 +128,7 @@ lib/galaxy/webapps/__init__.py lib/galaxy/webapps/reports/config.py lib/galaxy/webapps/reports/controllers/__init__.py lib/galaxy/webapps/reports/controllers/query.py +lib/galaxy/webapps/reports/controllers/tools.py lib/galaxy/webapps/reports/__init__.py lib/galaxy/webapps/tool_shed/api/__init__.py lib/galaxy/webapps/tool_shed/controllers/groups.py diff --git a/.ci/py3_sources.txt b/.ci/py3_sources.txt index 1dd598e6bba..bb4f6917f03 100644 --- a/.ci/py3_sources.txt +++ b/.ci/py3_sources.txt @@ -70,6 +70,7 @@ scripts/communication/ scripts/data_libraries/build_whoosh_index.py scripts/db_shell.py scripts/drmaa_external_runner.py +scripts/metagenomics/ scripts/secret_decoder_ring.py test/ tool_list.py diff --git a/contrib/galaxy_config_merger.py b/contrib/galaxy_config_merger.py index 38b5d3cc6aa..d813dbb7b80 100644 --- a/contrib/galaxy_config_merger.py +++ b/contrib/galaxy_config_merger.py @@ -80,9 +80,6 @@ def main(): config_sample.write(outputfile) outputfile.close() else: - # print "----------" - # config_sample.write(sys.stdout) - # print "----------" logging.info("use -o OUTPUT to write the merged configuration into a file.") logging.info("read Galaxy galaxy.ini.sample for detailed information.") diff --git a/lib/galaxy/datatypes/converters/bed_to_gff_converter.py b/lib/galaxy/datatypes/converters/bed_to_gff_converter.py index ce647167766..6507257d022 100644 --- a/lib/galaxy/datatypes/converters/bed_to_gff_converter.py +++ b/lib/galaxy/datatypes/converters/bed_to_gff_converter.py @@ -4,7 +4,7 @@ from __future__ import print_function import sys -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) def __main__(): diff --git a/lib/galaxy/datatypes/converters/gff_to_bed_converter.py b/lib/galaxy/datatypes/converters/gff_to_bed_converter.py index 60435054e34..9e9f767e80a 100644 --- a/lib/galaxy/datatypes/converters/gff_to_bed_converter.py +++ b/lib/galaxy/datatypes/converters/gff_to_bed_converter.py @@ -3,7 +3,7 @@ from __future__ import print_function import sys -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) def __main__(): diff --git a/lib/galaxy/datatypes/converters/interval_to_bed_converter.py b/lib/galaxy/datatypes/converters/interval_to_bed_converter.py index 48b0dd579ea..da2bdd1b86f 100644 --- a/lib/galaxy/datatypes/converters/interval_to_bed_converter.py +++ b/lib/galaxy/datatypes/converters/interval_to_bed_converter.py @@ -6,7 +6,7 @@ import sys import bx.intervals.io -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) def stop_err(msg): diff --git a/lib/galaxy/datatypes/converters/interval_to_bedstrict_converter.py b/lib/galaxy/datatypes/converters/interval_to_bedstrict_converter.py index 04041cf575f..bde7292f8cf 100644 --- a/lib/galaxy/datatypes/converters/interval_to_bedstrict_converter.py +++ b/lib/galaxy/datatypes/converters/interval_to_bedstrict_converter.py @@ -6,7 +6,7 @@ import sys import bx.intervals.io -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) def stop_err(msg): diff --git a/lib/galaxy/datatypes/converters/maf_to_fasta_converter.py b/lib/galaxy/datatypes/converters/maf_to_fasta_converter.py index bd56734f389..af35321ba31 100644 --- a/lib/galaxy/datatypes/converters/maf_to_fasta_converter.py +++ b/lib/galaxy/datatypes/converters/maf_to_fasta_converter.py @@ -8,7 +8,7 @@ import bx.align.maf from galaxy.tools.util import maf_utilities -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) def __main__(): diff --git a/lib/galaxy/datatypes/converters/maf_to_interval_converter.py b/lib/galaxy/datatypes/converters/maf_to_interval_converter.py index 7223653052b..f8028902259 100644 --- a/lib/galaxy/datatypes/converters/maf_to_interval_converter.py +++ b/lib/galaxy/datatypes/converters/maf_to_interval_converter.py @@ -8,7 +8,7 @@ import bx.align.maf from galaxy.tools.util import maf_utilities -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) def __main__(): diff --git a/lib/galaxy/datatypes/converters/picard_interval_list_to_bed6_converter.py b/lib/galaxy/datatypes/converters/picard_interval_list_to_bed6_converter.py index f3783cceeb2..3c4b3bd69c5 100644 --- a/lib/galaxy/datatypes/converters/picard_interval_list_to_bed6_converter.py +++ b/lib/galaxy/datatypes/converters/picard_interval_list_to_bed6_converter.py @@ -4,7 +4,7 @@ from __future__ import print_function import sys -assert sys.version_info[:2] >= (2, 5) +assert sys.version_info[:2] >= (2, 6) HEADER_STARTS_WITH = ('@') diff --git a/lib/galaxy/datatypes/dataproviders/base.py b/lib/galaxy/datatypes/dataproviders/base.py index 7c3347478be..35b394bcaa5 100644 --- a/lib/galaxy/datatypes/dataproviders/base.py +++ b/lib/galaxy/datatypes/dataproviders/base.py @@ -260,8 +260,6 @@ class LimitedOffsetDataProvider(FilteredDataProvider): parent_gen = super(LimitedOffsetDataProvider, self).__iter__() for datum in parent_gen: self.num_data_returned -= 1 - # print 'self.num_data_returned:', self.num_data_returned - # print 'self.num_valid_data_read:', self.num_valid_data_read if self.num_valid_data_read > self.offset: self.num_data_returned += 1 diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py index ecfde77474e..b2292fb5396 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -4242,7 +4242,6 @@ class MetadataFile(StorableObject): return path except AttributeError: # In case we're not working with the history_dataset - # print "Caught AttributeError" path = os.path.join(Dataset.file_path, '_metadata_files', *directory_hash_id(self.id)) # Create directory if it does not exist try: diff --git a/lib/galaxy/model/search.py b/lib/galaxy/model/search.py index c8d39e5fd6d..d340124be77 100644 --- a/lib/galaxy/model/search.py +++ b/lib/galaxy/model/search.py @@ -122,7 +122,6 @@ class ViewQueryBaseClass(object): clazz, attribute = field.sqlalchemy_field sqlalchemy_field_value = getattr(clazz, attribute) if operator == "=": - # print field.sqlalchemy_field == right, field.sqlalchemy_field, right self.query = self.query.filter(sqlalchemy_field_value == right) elif operator == "!=": self.query = self.query.filter(sqlalchemy_field_value != right) @@ -166,7 +165,6 @@ def library_extended_metadata_filter(view, left, operator, right): view.state['extended_metadata_joined'] = True alias = aliased(ExtendedMetadataIndex) field = "/%s" % ("/".join(left.split(".")[1:])) - # print "FIELD", field view.query = view.query.filter( and_( ExtendedMetadata.id == alias.extended_metadata_id, @@ -313,7 +311,6 @@ def history_dataset_extended_metadata_filter(view, left, operator, right): view.state['extended_metadata_joined'] = True alias = aliased(ExtendedMetadataIndex) field = "/%s" % ("/".join(left.split(".")[1:])) - # print "FIELD", field view.query = view.query.filter( and_( ExtendedMetadata.id == alias.extended_metadata_id, diff --git a/lib/galaxy/objectstore/s3.py b/lib/galaxy/objectstore/s3.py index 34a2fc39d74..ea7863ccdb7 100644 --- a/lib/galaxy/objectstore/s3.py +++ b/lib/galaxy/objectstore/s3.py @@ -1,7 +1,6 @@ """ Object Store plugin for the Amazon Simple Storage Service (S3) """ - import logging import multiprocessing import os @@ -9,9 +8,17 @@ import shutil import subprocess import threading import time - from datetime import datetime +try: + # Imports are done this way to allow objectstore code to be used outside of Galaxy. + import boto + from boto.exception import S3ResponseError + from boto.s3.connection import S3Connection + from boto.s3.key import Key +except ImportError: + boto = None + from galaxy.exceptions import ObjectInvalid, ObjectNotFound from galaxy.util import ( directory_hash_id, @@ -25,16 +32,6 @@ from galaxy.util.sleeper import Sleeper from .s3_multipart_upload import multipart_upload from ..objectstore import convert_bytes, ObjectStore -try: - # Imports are done this way to allow objectstore code to be used outside of Galaxy. - import boto - - from boto.exception import S3ResponseError - from boto.s3.key import Key - from boto.s3.connection import S3Connection -except ImportError: - boto = None - NO_BOTO_ERROR_MESSAGE = ("S3/Swift object store configured, but no boto dependency available." "Please install and properly configure boto or modify object store configuration.") @@ -296,21 +293,21 @@ class S3ObjectStore(ObjectStore): # creates, this check sould be implemented- in the mean time, it's not # looking likely to be implementable reliably. # if os.path.exists(cache_path): - # # print "***1 %s exists" % cache_path + # # print("***1 %s exists" % cache_path) # if self._key_exists(rel_path): - # # print "***2 %s exists in S3" % rel_path + # # print("***2 %s exists in S3" % rel_path) # # Make sure the size in cache is available in its entirety - # # print "File '%s' cache size: %s, S3 size: %s" % (cache_path, os.path.getsize(cache_path), self._get_size_in_s3(rel_path)) + # # print("File '%s' cache size: %s, S3 size: %s" % (cache_path, os.path.getsize(cache_path), self._get_size_in_s3(rel_path))) # if os.path.getsize(cache_path) == self._get_size_in_s3(rel_path): - # # print "***2.1 %s exists in S3 and the size is the same as in cache (in_cache=True)" % rel_path + # # print("***2.1 %s exists in S3 and the size is the same as in cache (in_cache=True)" % rel_path) # exists = True # else: - # # print "***2.2 %s exists but differs in size from cache (in_cache=False)" % cache_path + # # print("***2.2 %s exists but differs in size from cache (in_cache=False)" % cache_path) # exists = False # else: # # Although not perfect decision making, this most likely means # # that the file is currently being uploaded - # # print "***3 %s found in cache but not in S3 (in_cache=True)" % cache_path + # # print("***3 %s found in cache but not in S3 (in_cache=True)" % cache_path) # exists = True # else: # return False diff --git a/lib/galaxy/tools/deps/containers.py b/lib/galaxy/tools/deps/containers.py index c7bb8f36b36..f3ca14c8552 100644 --- a/lib/galaxy/tools/deps/containers.py +++ b/lib/galaxy/tools/deps/containers.py @@ -35,7 +35,13 @@ ALL_CONTAINER_TYPES = [DOCKER_CONTAINER_TYPE, SINGULARITY_CONTAINER_TYPE] LOAD_CACHED_IMAGE_COMMAND_TEMPLATE = ''' python << EOF -import re, tarfile, json, subprocess +from __future__ import print_function + +import json +import re +import subprocess +import tarfile + t = tarfile.TarFile("${cached_image_file}") meta_str = t.extractfile('repositories').read() meta = json.loads(meta_str) @@ -50,7 +56,7 @@ for line in stdo.split("\\n"): if tmp[0] == tag and tmp[1] == rev and tmp[2] == rev_value: found = True if not found: - print "Loading image" + print("Loading image") cmd = "cat ${cached_image_file} | ${load_cmd}" subprocess.check_call(cmd, shell=True) EOF diff --git a/lib/galaxy/tools/imp_exp/__init__.py b/lib/galaxy/tools/imp_exp/__init__.py index 962aa423e6b..2389f2c87ff 100644 --- a/lib/galaxy/tools/imp_exp/__init__.py +++ b/lib/galaxy/tools/imp_exp/__init__.py @@ -271,14 +271,12 @@ class JobImportHistoryArchiveWrapper(object, UsesAnnotations): input_hda = self.sa_session.query(model.HistoryDatasetAssociation) \ .filter_by(history=new_history, hid=value.hid).first() value = input_hda.id - # print "added parameter %s-->%s to job %i" % ( name, value, imported_job.id ) imported_job.add_parameter(name, dumps(value, cls=HistoryDatasetAssociationIDEncoder)) # TODO: Connect jobs to input datasets. # Connect jobs to output datasets. for output_hid in job_attrs['output_datasets']: - # print "%s job has output dataset %i" % (imported_job.id, output_hid) output_hda = self.sa_session.query(model.HistoryDatasetAssociation) \ .filter_by(history=new_history, hid=output_hid).first() if output_hda: diff --git a/lib/galaxy/tools/parameters/__init__.py b/lib/galaxy/tools/parameters/__init__.py index c778551c401..ea3f3b826b2 100644 --- a/lib/galaxy/tools/parameters/__init__.py +++ b/lib/galaxy/tools/parameters/__init__.py @@ -1,6 +1,8 @@ """ Classes encapsulating Galaxy tool parameters. """ +from __future__ import print_function + import re from json import dumps @@ -49,7 +51,7 @@ def visit_input_values(inputs, input_values, callback, name_prefix='', label_pre >>> f.cases = [Bunch(value='true', inputs= { 'h': h }), Bunch(value='false', inputs= { 'i': i })] >>> >>> def visitor(input, value, prefix, prefixed_name, **kwargs): - ... print 'name=%s, prefix=%s, prefixed_name=%s, value=%s' % (input.name, prefix, prefixed_name, value) + ... print('name=%s, prefix=%s, prefixed_name=%s, value=%s' % (input.name, prefix, prefixed_name, value)) >>> inputs = odict([('a',a),('b',b)]) >>> nested = odict([('a', 1), ('b', [odict([('c', 3), ('d', [odict([('e', 5), ('f', odict([('g', True), ('h', 7)]))])])])])]) >>> visit_input_values(inputs, nested, visitor) @@ -249,13 +251,13 @@ def populate_state(request_context, inputs, incoming, state, errors={}, prefix=' >>> flat = odict([('a', 1), ('b_0|c', 2), ('b_0|d_0|e', 3), ('b_0|d_0|f|h', 4), ('b_0|d_0|f|g', True)]) >>> state = odict() >>> populate_state(trans, inputs, flat, state, check=False) - >>> print state['a'] + >>> print(state['a']) 1 - >>> print state['b'][0]['c'] + >>> print(state['b'][0]['c']) 2 - >>> print state['b'][0]['d'][0]['e'] + >>> print(state['b'][0]['d'][0]['e']) 3 - >>> print state['b'][0]['d'][0]['f']['h'] + >>> print(state['b'][0]['d'][0]['f']['h']) 4 """ context = ExpressionContext(state, context) diff --git a/lib/galaxy/tools/parameters/input_translation.py b/lib/galaxy/tools/parameters/input_translation.py index 1917a7885ae..c9f36929396 100644 --- a/lib/galaxy/tools/parameters/input_translation.py +++ b/lib/galaxy/tools/parameters/input_translation.py @@ -1,6 +1,8 @@ """ Tool Input Translation. """ +from __future__ import print_function + import logging from galaxy.util.bunch import Bunch @@ -43,7 +45,7 @@ class ToolInputTranslator(object): ... ''')) >>> params = Params({'db':'hg17', 'URL':'URL_value', 'org':'Human', 'hgta_outputType':'primaryTable'}) >>> translator.translate(params) - >>> print sorted(list(params.__dict__.keys())) + >>> print(sorted(params.__dict__.keys())) ['URL', 'URL_method', 'data_type', 'db', 'dbkey', 'description', 'hgta_outputType', 'org', 'organism', 'table'] >>> params.get('URL', None) in ['URL_value?GALAXY_URL=0&_export=1', 'URL_value?_export=1&GALAXY_URL=0'] True diff --git a/lib/galaxy/tools/util/maf_utilities.py b/lib/galaxy/tools/util/maf_utilities.py index 7c9d7be22ff..2851cf2cac2 100644 --- a/lib/galaxy/tools/util/maf_utilities.py +++ b/lib/galaxy/tools/util/maf_utilities.py @@ -19,7 +19,7 @@ import bx.interval_index_file import bx.intervals from six.moves import xrange -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) log = logging.getLogger(__name__) diff --git a/lib/galaxy/util/jstree.py b/lib/galaxy/util/jstree.py index 9f20d66bc22..fb4543ea626 100644 --- a/lib/galaxy/util/jstree.py +++ b/lib/galaxy/util/jstree.py @@ -1,8 +1,11 @@ -import os +from __future__ import print_function + import copy -import dictobj +import os from collections import namedtuple +import dictobj + Path = namedtuple('Path', ('path', 'id', 'options')) @@ -46,23 +49,23 @@ class Node(dictobj.DictionaryObject): Example: >>> import jstree >>> node = jstree.Node('a', None) - >>> print node + >>> print(node) Node({'text': 'a', 'children': MutableDictionaryObject({})}) - >>> print node.jsonData() + >>> print(node.jsonData()) {'text': 'a'} >>> import jstree >>> node = jstree.Node('a', 1) - >>> print node + >>> print(node) Node({'text': 'a', 'children': MutableDictionaryObject({}), 'li_attr': DictionaryObject({'id': 1}), 'id': 1}) - >>> print node.jsonData() + >>> print(node.jsonData()) {'text': 'a', 'id': 1, 'li_attr': {'id': 1}} >>> import jstree >>> node = jstree.Node('a', 5, icon="folder", state = {'opened': True}) - >>> print node + >>> print(node) Node({'text': 'a', 'id': 5, 'state': DictionaryObject({'opened': True}), 'children': MutableDictionaryObject({}), 'li_attr': DictionaryObject({'id': 5}), 'icon': 'folder'}) - >>> print node.jsonData() + >>> print(node.jsonData()) {'text': 'a', 'state': {'opened': True}, 'id': 5, 'li_attr': {'id': 5}, 'icon': 'folder'} """ super(Node, self).__init__() diff --git a/lib/galaxy/visualization/data_providers/basic.py b/lib/galaxy/visualization/data_providers/basic.py index 456ffaa420c..8695db08464 100644 --- a/lib/galaxy/visualization/data_providers/basic.py +++ b/lib/galaxy/visualization/data_providers/basic.py @@ -104,7 +104,6 @@ class ColumnDataProvider(BaseDataProvider): (column >= 0)), ( "column index (%d) must be positive and less" % (column) + " than the number of columns: %d" % (self.original_dataset.metadata.columns)) - # print columns, start_val, max_vals, skip_comments, kwargs # set up the response, column lists response = {} diff --git a/lib/galaxy/web/form_builder.py b/lib/galaxy/web/form_builder.py index ffb9cbbdb0d..c138e00c747 100644 --- a/lib/galaxy/web/form_builder.py +++ b/lib/galaxy/web/form_builder.py @@ -1,10 +1,13 @@ """ Classes for generating HTML forms """ +from __future__ import print_function + import logging -from six import string_types from cgi import escape +from six import string_types + from galaxy.util import restore_text, unicodify log = logging.getLogger(__name__) @@ -44,9 +47,9 @@ class TextField(BaseField): """ A standard text input box. - >>> print TextField( "foo" ).get_html() + >>> print(TextField( "foo" ).get_html()) - >>> print TextField( "bins", size=4, value="default" ).get_html() + >>> print(TextField( "bins", size=4, value="default" ).get_html()) """ @@ -72,9 +75,9 @@ class PasswordField(BaseField): """ A password input box. text appears as "******" - >>> print PasswordField( "foo" ).get_html() + >>> print(PasswordField( "foo" ).get_html()) - >>> print PasswordField( "bins", size=4, value="default" ).get_html() + >>> print(PasswordField( "bins", size=4, value="default" ).get_html()) """ @@ -101,9 +104,9 @@ class TextArea(BaseField): """ A standard text area box. - >>> print TextArea( "foo" ).get_html() + >>> print(TextArea( "foo" ).get_html()) - >>> print TextArea( "bins", size="4x5", value="default" ).get_html() + >>> print(TextArea( "bins", size="4x5", value="default" ).get_html()) """ _DEFAULT_SIZE = "5x25" @@ -136,9 +139,9 @@ class CheckboxField(BaseField): """ A checkbox (boolean input) - >>> print CheckboxField( "foo" ).get_html() + >>> print(CheckboxField( "foo" ).get_html()) - >>> print CheckboxField( "bar", checked="yes" ).get_html() + >>> print(CheckboxField( "bar", checked="yes" ).get_html()) """ @@ -186,9 +189,9 @@ class FileField(BaseField): """ A file upload input. - >>> print FileField( "foo" ).get_html() + >>> print(FileField( "foo" ).get_html()) - >>> print FileField( "foo", ajax = True ).get_html() + >>> print(FileField( "foo", ajax = True ).get_html()) """ @@ -233,7 +236,7 @@ class HiddenField(BaseField): """ A hidden field. - >>> print HiddenField( "foo", 100 ).get_html() + >>> print(HiddenField( "foo", 100 ).get_html()) """ @@ -259,7 +262,7 @@ class SelectField(BaseField): >>> t = SelectField( "foo", multiple=True ) >>> t.add_option( "tuti", 1 ) >>> t.add_option( "fruity", "x" ) - >>> print t.get_html() + >>> print(t.get_html()) @@ -277,14 +280,14 @@ class SelectField(BaseField): >>> t = SelectField( "foo", display="radio" ) >>> t.add_option( "tuti", 1 ) >>> t.add_option( "fruity", "x" ) - >>> print t.get_html() + >>> print(t.get_html())
>>> t = SelectField( "bar", multiple=True, display="checkboxes" ) >>> t.add_option( "automatic", 3 ) >>> t.add_option( "bazooty", 4, selected=True ) - >>> print t.get_html() + >>> print(t.get_html())
diff --git a/lib/galaxy/webapps/reports/controllers/tools.py b/lib/galaxy/webapps/reports/controllers/tools.py index 39037e779e9..7128c65ffe1 100644 --- a/lib/galaxy/webapps/reports/controllers/tools.py +++ b/lib/galaxy/webapps/reports/controllers/tools.py @@ -1,15 +1,15 @@ - import collections import logging -import galaxy.model -import sqlalchemy as sa +from datetime import timedelta +import sqlalchemy as sa +from markupsafe import escape +from sqlalchemy import and_ + +import galaxy.model from galaxy import util from galaxy.web.base.controller import BaseUIController, web -from sqlalchemy import and_ -from datetime import timedelta -from markupsafe import escape log = logging.getLogger(__name__) @@ -344,7 +344,6 @@ class Tools(BaseUIController): if word in to_replace: continue if words.count(word) > 1: - print word to_replace.append(word) for word in to_replace: sentence = ("
" + word) * 2 @@ -352,7 +351,6 @@ class Tools(BaseUIController): while sentence + "
" + word in new_key: sentence += "
" + word count += 1 - print sentence, count if sentence in new_key: new_key = new_key.replace(sentence, '
' + word + " [this line in %d times]" % (count)) data[new_key] = counter[key] diff --git a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0001_initial_tables.py b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0001_initial_tables.py index 77c6d8e15f9..84b5e7ffb94 100644 --- a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0001_initial_tables.py +++ b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0001_initial_tables.py @@ -1,6 +1,8 @@ """ Migration script to create initial tables. """ +from __future__ import print_function + import datetime import logging import sys @@ -145,7 +147,7 @@ ToolAnnotationAssociation_table = Table("tool_annotation_association", metadata, def upgrade(migrate_engine): - print __doc__ + print(__doc__) metadata.bind = migrate_engine metadata.create_all() Index('ix_tool_annotation_association_annotation', ToolAnnotationAssociation_table.c.annotation, mysql_length=767).create() diff --git a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0002_add_tool_suite_column.py b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0002_add_tool_suite_column.py index a7b6b02993d..25028379f66 100644 --- a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0002_add_tool_suite_column.py +++ b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0002_add_tool_suite_column.py @@ -1,6 +1,8 @@ """ Migration script to add the suite column to the tool table. """ +from __future__ import print_function + import logging import sys @@ -19,7 +21,7 @@ metadata = MetaData() def upgrade(migrate_engine): metadata.bind = migrate_engine - print __doc__ + print(__doc__) metadata.reflect() # Create and initialize imported column in job table. Tool_table = Table("tool", metadata, autoload=True) @@ -34,9 +36,8 @@ def upgrade(migrate_engine): elif migrate_engine.name in ['postgresql', 'postgres']: default_false = "false" migrate_engine.execute("UPDATE tool SET suite=%s" % default_false) - except Exception as e: - print "Adding suite column to the tool table failed: %s" % str(e) - log.debug("Adding suite column to the tool table failed: %s" % str(e)) + except Exception: + log.exception("Adding suite column to the tool table failed.") def downgrade(migrate_engine): @@ -46,6 +47,5 @@ def downgrade(migrate_engine): Tool_table = Table("tool", metadata, autoload=True) try: Tool_table.c.suite.drop() - except Exception as e: - print "Dropping column suite from the tool table failed: %s" % str(e) - log.debug("Dropping column suite from the tool table failed: %s" % str(e)) + except Exception: + log.exception("Dropping column suite from the tool table failed.") diff --git a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0003_review_and_review_association_tables.py b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0003_review_and_review_association_tables.py index 1577a1a63a1..4a5d97573db 100644 --- a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0003_review_and_review_association_tables.py +++ b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0003_review_and_review_association_tables.py @@ -1,6 +1,8 @@ """ Adds the tool_rating_association table, enabling tools to be rated along with review comments. """ +from __future__ import print_function + import datetime import logging import sys @@ -29,14 +31,14 @@ ToolRatingAssociation_table = Table("tool_rating_association", metadata, def upgrade(migrate_engine): - print __doc__ + print(__doc__) metadata.bind = migrate_engine # Load existing tables metadata.reflect() try: ToolRatingAssociation_table.create() - except Exception as e: - log.debug("Creating tool_rating_association table failed: %s" % str(e)) + except Exception: + log.exception("Creating tool_rating_association table failed.") def downgrade(migrate_engine): @@ -45,5 +47,5 @@ def downgrade(migrate_engine): metadata.reflect() try: ToolRatingAssociation_table.drop() - except Exception as e: - log.debug("Dropping tool_rating_association table failed: %s" % str(e)) + except Exception: + log.exception("Dropping tool_rating_association table failed.") diff --git a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0004_repository_tables.py b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0004_repository_tables.py index 5c439eae6cb..c27f329bc3d 100644 --- a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0004_repository_tables.py +++ b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0004_repository_tables.py @@ -1,6 +1,8 @@ """ Adds the repository, repository_rating_association and repository_category_association tables. """ +from __future__ import print_function + import datetime import logging import sys @@ -47,22 +49,22 @@ RepositoryCategoryAssociation_table = Table("repository_category_association", m def upgrade(migrate_engine): - print __doc__ + print(__doc__) # Load existing tables metadata.bind = migrate_engine metadata.reflect() try: Repository_table.create() - except Exception as e: - log.debug("Creating repository table failed: %s" % str(e)) + except Exception: + log.exception("Creating repository table failed.") try: RepositoryRatingAssociation_table.create() - except Exception as e: - log.debug("Creating repository_rating_association table failed: %s" % str(e)) + except Exception: + log.exception("Creating repository_rating_association table failed.") try: RepositoryCategoryAssociation_table.create() - except Exception as e: - log.debug("Creating repository_category_association table failed: %s" % str(e)) + except Exception: + log.exception("Creating repository_category_association table failed.") def downgrade(migrate_engine): @@ -71,13 +73,13 @@ def downgrade(migrate_engine): metadata.reflect() try: Repository_table.drop() - except Exception as e: - log.debug("Dropping repository table failed: %s" % str(e)) + except Exception: + log.exception("Dropping repository table failed.") try: RepositoryRatingAssociation_table.drop() - except Exception as e: - log.debug("Dropping repository_rating_association table failed: %s" % str(e)) + except Exception: + log.exception("Dropping repository_rating_association table failed.") try: RepositoryCategoryAssociation_table.drop() - except Exception as e: - log.debug("Dropping repository_category_association table failed: %s" % str(e)) + except Exception: + log.exception("Dropping repository_category_association table failed.") diff --git a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0005_drop_tool_related_tables.py b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0005_drop_tool_related_tables.py index df60b0f3358..309b4fac71f 100644 --- a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0005_drop_tool_related_tables.py +++ b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0005_drop_tool_related_tables.py @@ -3,6 +3,8 @@ Drops the tool, tool_category_association, event, tool_event_association, tool_r tool_tag_association and tool_annotation_association tables since they are no longer used in the next-gen tool shed. """ +from __future__ import print_function + import datetime import logging import sys @@ -26,7 +28,7 @@ metadata = MetaData() def upgrade(migrate_engine): - print __doc__ + print(__doc__) # Load existing tables metadata.bind = migrate_engine metadata.reflect() @@ -37,8 +39,8 @@ def upgrade(migrate_engine): log.debug("Failed loading table tool_category_association") try: ToolCategoryAssociation_table.drop() - except Exception as e: - log.debug("Dropping tool_category_association table failed: %s" % str(e)) + except Exception: + log.exception("Dropping tool_category_association table failed.") # Load and then drop the tool_event_association table try: ToolEventAssociation_table = Table("tool_event_association", metadata, autoload=True) @@ -46,8 +48,8 @@ def upgrade(migrate_engine): log.debug("Failed loading table tool_event_association") try: ToolEventAssociation_table.drop() - except Exception as e: - log.debug("Dropping tool_event_association table failed: %s" % str(e)) + except Exception: + log.exception("Dropping tool_event_association table failed.") # Load and then drop the tool_rating_association table try: ToolRatingAssociation_table = Table("tool_rating_association", metadata, autoload=True) @@ -55,8 +57,8 @@ def upgrade(migrate_engine): log.debug("Failed loading table tool_rating_association") try: ToolRatingAssociation_table.drop() - except Exception as e: - log.debug("Dropping tool_rating_association table failed: %s" % str(e)) + except Exception: + log.exception("Dropping tool_rating_association table failed.") # Load and then drop the tool_tag_association table try: ToolTagAssociation_table = Table("tool_tag_association", metadata, autoload=True) @@ -64,8 +66,8 @@ def upgrade(migrate_engine): log.debug("Failed loading table tool_tag_association") try: ToolTagAssociation_table.drop() - except Exception as e: - log.debug("Dropping tool_tag_association table failed: %s" % str(e)) + except Exception: + log.exception("Dropping tool_tag_association table failed.") # Load and then drop the tool_annotation_association table try: ToolAnnotationAssociation_table = Table("tool_annotation_association", metadata, autoload=True) @@ -73,8 +75,8 @@ def upgrade(migrate_engine): log.debug("Failed loading table tool_annotation_association") try: ToolAnnotationAssociation_table.drop() - except Exception as e: - log.debug("Dropping tool_annotation_association table failed: %s" % str(e)) + except Exception: + log.exception("Dropping tool_annotation_association table failed.") # Load and then drop the event table try: Event_table = Table("event", metadata, autoload=True) @@ -82,8 +84,8 @@ def upgrade(migrate_engine): log.debug("Failed loading table event") try: Event_table.drop() - except Exception as e: - log.debug("Dropping event table failed: %s" % str(e)) + except Exception: + log.exception("Dropping event table failed.") # Load and then drop the tool table try: Tool_table = Table("tool", metadata, autoload=True) @@ -91,8 +93,8 @@ def upgrade(migrate_engine): log.debug("Failed loading table tool") try: Tool_table.drop() - except Exception as e: - log.debug("Dropping tool table failed: %s" % str(e)) + except Exception: + log.exception("Dropping tool table failed.") def downgrade(migrate_engine): @@ -161,35 +163,35 @@ def downgrade(migrate_engine): # Create the event table try: Event_table.create() - except Exception as e: - log.debug("Creating event table failed: %s" % str(e)) + except Exception: + log.exception("Creating event table failed.") # Create the tool table try: Tool_table.create() - except Exception as e: - log.debug("Creating tool table failed: %s" % str(e)) + except Exception: + log.exception("Creating tool table failed.") # Create the tool_category_association table try: ToolCategoryAssociation_table.create() - except Exception as e: - log.debug("Creating tool_category_association table failed: %s" % str(e)) + except Exception: + log.exception("Creating tool_category_association table failed.") # Create the tool_event_association table try: ToolEventAssociation_table.create() - except Exception as e: - log.debug("Creating tool_event_association table failed: %s" % str(e)) + except Exception: + log.exception("Creating tool_event_association table failed.") # Create the tool_rating_association table try: ToolRatingAssociation_table.create() - except Exception as e: - log.debug("Creating tool_rating_association table failed: %s" % str(e)) + except Exception: + log.exception("Creating tool_rating_association table failed.") # Create the tool_tag_association table try: ToolTagAssociation_table.create() - except Exception as e: - log.debug("Creating tool_tag_association table failed: %s" % str(e)) + except Exception: + log.exception("Creating tool_tag_association table failed.") # Create the tool_annotation_association table try: ToolAnnotationAssociation_table.create() - except Exception as e: - log.debug("Creating tool_annotation_association table failed: %s" % str(e)) + except Exception: + log.exception("Creating tool_annotation_association table failed.") diff --git a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0006_add_email_alerts_column.py b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0006_add_email_alerts_column.py index 20620f11a81..48b6783113f 100644 --- a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0006_add_email_alerts_column.py +++ b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0006_add_email_alerts_column.py @@ -1,6 +1,8 @@ """ Migration script to add the email_alerts column to the repository table. """ +from __future__ import print_function + import logging import sys @@ -21,7 +23,7 @@ metadata = MetaData() def upgrade(migrate_engine): - print __doc__ + print(__doc__) metadata.bind = migrate_engine metadata.reflect() # Create and initialize imported column in job table. @@ -31,9 +33,8 @@ def upgrade(migrate_engine): # Create c.create(Repository_table) assert c is Repository_table.c.email_alerts - except Exception as e: - print "Adding email_alerts column to the repository table failed: %s" % str(e) - log.debug("Adding email_alerts column to the repository table failed: %s" % str(e)) + except Exception: + log.exception("Adding email_alerts column to the repository table failed.") def downgrade(migrate_engine): @@ -43,6 +44,5 @@ def downgrade(migrate_engine): Repository_table = Table("repository", metadata, autoload=True) try: Repository_table.c.email_alerts.drop() - except Exception as e: - print "Dropping column email_alerts from the repository table failed: %s" % str(e) - log.debug("Dropping column email_alerts from the repository table failed: %s" % str(e)) + except Exception: + log.exception("Dropping column email_alerts from the repository table failed.") diff --git a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0007_add_long_description_times_downloaded_columns.py b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0007_add_long_description_times_downloaded_columns.py index c4d4733b5a6..e62f605c0a9 100644 --- a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0007_add_long_description_times_downloaded_columns.py +++ b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0007_add_long_description_times_downloaded_columns.py @@ -1,6 +1,8 @@ """ Migration script to add the long_description and times_downloaded columns to the repository table. """ +from __future__ import print_function + import logging import sys @@ -18,7 +20,7 @@ metadata = MetaData() def upgrade(migrate_engine): - print __doc__ + print(__doc__) metadata.bind = migrate_engine metadata.reflect() # Create and initialize imported column in job table. @@ -28,18 +30,16 @@ def upgrade(migrate_engine): # Create c.create(Repository_table) assert c is Repository_table.c.long_description - except Exception as e: - print "Adding long_description column to the repository table failed: %s" % str(e) - log.debug("Adding long_description column to the repository table failed: %s" % str(e)) + except Exception: + log.exception("Adding long_description column to the repository table failed.") c = Column("times_downloaded", Integer) try: # Create c.create(Repository_table) assert c is Repository_table.c.times_downloaded - except Exception as e: - print "Adding times_downloaded column to the repository table failed: %s" % str(e) - log.debug("Adding times_downloaded column to the repository table failed: %s" % str(e)) + except Exception: + log.exception("Adding times_downloaded column to the repository table failed.") cmd = "UPDATE repository SET long_description = ''" migrate_engine.execute(cmd) @@ -54,11 +54,9 @@ def downgrade(migrate_engine): Repository_table = Table("repository", metadata, autoload=True) try: Repository_table.c.long_description.drop() - except Exception as e: - print "Dropping column long_description from the repository table failed: %s" % str(e) - log.debug("Dropping column long_description from the repository table failed: %s" % str(e)) + except Exception: + log.exception("Dropping column long_description from the repository table failed.") try: Repository_table.c.times_downloaded.drop() - except Exception as e: - print "Dropping column times_downloaded from the repository table failed: %s" % str(e) - log.debug("Dropping column times_downloaded from the repository table failed: %s" % str(e)) + except Exception: + log.exception("Dropping column times_downloaded from the repository table failed.") diff --git a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0008_add_repository_metadata_table.py b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0008_add_repository_metadata_table.py index e471022f3b2..60cb39e84ba 100644 --- a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0008_add_repository_metadata_table.py +++ b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0008_add_repository_metadata_table.py @@ -1,6 +1,8 @@ """ Migration script to add the repository_metadata table. """ +from __future__ import print_function + import datetime import logging import sys @@ -31,15 +33,14 @@ RepositoryMetadata_table = Table("repository_metadata", metadata, def upgrade(migrate_engine): - print __doc__ + print(__doc__) metadata.bind = migrate_engine metadata.reflect() # Create repository_metadata table. try: RepositoryMetadata_table.create() - except Exception as e: - print str(e) - log.debug("Creating repository_metadata table failed: %s" % str(e)) + except Exception: + log.exception("Creating repository_metadata table failed.") def downgrade(migrate_engine): @@ -48,6 +49,5 @@ def downgrade(migrate_engine): # Drop repository_metadata table. try: RepositoryMetadata_table.drop() - except Exception as e: - print str(e) - log.debug("Dropping repository_metadata table failed: %s" % str(e)) + except Exception: + log.exception("Dropping repository_metadata table failed.") diff --git a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0009_add_malicious_column.py b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0009_add_malicious_column.py index 698a64c397d..1440bf388fa 100644 --- a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0009_add_malicious_column.py +++ b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0009_add_malicious_column.py @@ -1,6 +1,8 @@ """ Migration script to add the malicious column to the repository_metadata table. """ +from __future__ import print_function + import logging import sys @@ -18,7 +20,7 @@ metadata = MetaData() def upgrade(migrate_engine): - print __doc__ + print(__doc__) metadata.bind = migrate_engine metadata.reflect() # Create and initialize imported column in job table. @@ -34,9 +36,8 @@ def upgrade(migrate_engine): elif migrate_engine.name in ['postgresql', 'postgres']: default_false = "false" migrate_engine.execute("UPDATE repository_metadata SET malicious=%s" % default_false) - except Exception as e: - print "Adding malicious column to the repository_metadata table failed: %s" % str(e) - log.debug("Adding malicious column to the repository_metadata table failed: %s" % str(e)) + except Exception: + log.exception("Adding malicious column to the repository_metadata table failed.") def downgrade(migrate_engine): @@ -46,6 +47,5 @@ def downgrade(migrate_engine): Repository_metadata_table = Table("repository_metadata", metadata, autoload=True) try: Repository_metadata_table.c.malicious.drop() - except Exception as e: - print "Dropping column malicious from the repository_metadata table failed: %s" % str(e) - log.debug("Dropping column malicious from the repository_metadata table failed: %s" % str(e)) + except Exception: + log.exception("Dropping column malicious from the repository_metadata table failed.") diff --git a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0010_add_new_repo_alert_column.py b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0010_add_new_repo_alert_column.py index 3464c90bedc..afbefe520dc 100644 --- a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0010_add_new_repo_alert_column.py +++ b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0010_add_new_repo_alert_column.py @@ -1,6 +1,8 @@ """ Migration script to add the new_repo_alert column to the galaxy_user table. """ +from __future__ import print_function + import logging import sys @@ -18,7 +20,7 @@ metadata = MetaData() def upgrade(migrate_engine): - print __doc__ + print(__doc__) metadata.bind = migrate_engine metadata.reflect() # Create and initialize imported column in job table. @@ -36,9 +38,8 @@ def upgrade(migrate_engine): else: log.debug("unknown migrate_engine dialect") migrate_engine.execute("UPDATE galaxy_user SET new_repo_alert=%s" % default_false) - except Exception as e: - print "Adding new_repo_alert column to the galaxy_user table failed: %s" % str(e) - log.debug("Adding new_repo_alert column to the galaxy_user table failed: %s" % str(e)) + except Exception: + log.exception("Adding new_repo_alert column to the galaxy_user table failed.") def downgrade(migrate_engine): @@ -48,6 +49,5 @@ def downgrade(migrate_engine): User_table = Table("galaxy_user", metadata, autoload=True) try: User_table.c.new_repo_alert.drop() - except Exception as e: - print "Dropping column new_repo_alert from the galaxy_user table failed: %s" % str(e) - log.debug("Dropping column new_repo_alert from the galaxy_user table failed: %s" % str(e)) + except Exception: + log.exception("Dropping column new_repo_alert from the galaxy_user table failed.") diff --git a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0011_add_tool_versions_column.py b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0011_add_tool_versions_column.py index eca914eb8b2..052af304c73 100644 --- a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0011_add_tool_versions_column.py +++ b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0011_add_tool_versions_column.py @@ -1,6 +1,8 @@ """ Migration script to add the tool_versions column to the repository_metadata table. """ +from __future__ import print_function + import datetime import logging import sys @@ -23,7 +25,7 @@ metadata = MetaData() def upgrade(migrate_engine): - print __doc__ + print(__doc__) metadata.bind = migrate_engine metadata.reflect() RepositoryMetadata_table = Table("repository_metadata", metadata, autoload=True) @@ -32,8 +34,8 @@ def upgrade(migrate_engine): # Create c.create(RepositoryMetadata_table) assert c is RepositoryMetadata_table.c.tool_versions - except Exception as e: - print "Adding tool_versions column to the repository_metadata table failed: %s" % str(e) + except Exception: + log.exception("Adding tool_versions column to the repository_metadata table failed.") def downgrade(migrate_engine): @@ -43,5 +45,5 @@ def downgrade(migrate_engine): RepositoryMetadata_table = Table("repository_metadata", metadata, autoload=True) try: RepositoryMetadata_table.c.tool_versions.drop() - except Exception as e: - print "Dropping column tool_versions from the repository_metadata table failed: %s" % str(e) + except Exception: + log.exception("Dropping column tool_versions from the repository_metadata table failed.") diff --git a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0012_add_downloadable_column.py b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0012_add_downloadable_column.py index 553043a61f0..4f6a1f92f16 100644 --- a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0012_add_downloadable_column.py +++ b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0012_add_downloadable_column.py @@ -1,6 +1,8 @@ """ Migration script to add the downloadable column to the repository_metadata table. """ +from __future__ import print_function + import logging import sys @@ -18,7 +20,7 @@ metadata = MetaData() def upgrade(migrate_engine): - print __doc__ + print(__doc__) metadata.bind = migrate_engine metadata.reflect() # Create and initialize imported column in job table. @@ -34,8 +36,8 @@ def upgrade(migrate_engine): elif migrate_engine.name in ['postgresql', 'postgres']: default_true = "true" migrate_engine.execute("UPDATE repository_metadata SET downloadable=%s" % default_true) - except Exception as e: - print "Adding downloadable column to the repository_metadata table failed: %s" % str(e) + except Exception: + log.exception("Adding downloadable column to the repository_metadata table failed.") def downgrade(migrate_engine): @@ -45,5 +47,5 @@ def downgrade(migrate_engine): RepositoryMetadata_table = Table("repository_metadata", metadata, autoload=True) try: RepositoryMetadata_table.c.downloadable.drop() - except Exception as e: - print "Dropping column downloadable from the repository_metadata table failed: %s" % str(e) + except Exception: + log.exception("Dropping column downloadable from the repository_metadata table failed.") diff --git a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0013_add_review_tables.py b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0013_add_review_tables.py index ee7120772dc..2936e4a8fd4 100644 --- a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0013_add_review_tables.py +++ b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0013_add_review_tables.py @@ -1,6 +1,8 @@ """ Migration script to add the repository_review, component_review and component tables and the Repository Reviewer group and role. """ +from __future__ import print_function + import datetime import logging import sys @@ -83,25 +85,22 @@ Component_table = Table("component", metadata, def upgrade(migrate_engine): - print __doc__ + print(__doc__) metadata.bind = migrate_engine metadata.reflect() # Create new review tables. try: Component_table.create() - except Exception as e: - print str(e) - log.debug("Creating component table failed: %s" % str(e)) + except Exception: + log.exception("Creating component table failed.") try: RepositoryReview_table.create() - except Exception as e: - print str(e) - log.debug("Creating repository_review table failed: %s" % str(e)) + except Exception: + log.exception("Creating repository_review table failed.") try: ComponentReview_table.create() - except Exception as e: - print str(e) - log.debug("Creating component_review table failed: %s" % str(e)) + except Exception: + log.exception("Creating component_review table failed.") # Insert default Component values. names = ['Data types', 'Functional tests', 'README', 'Tool dependencies', 'Tools', 'Workflows'] descriptions = ['Proprietary datatypes defined in a file named datatypes_conf.xml included in the repository', @@ -170,19 +169,16 @@ def downgrade(migrate_engine): # Drop review tables. try: ComponentReview_table.drop() - except Exception as e: - print str(e) - log.debug("Dropping component_review table failed: %s" % str(e)) + except Exception: + log.exception("Dropping component_review table failed.") try: RepositoryReview_table.drop() - except Exception as e: - print str(e) - log.debug("Dropping repository_review table failed: %s" % str(e)) + except Exception: + log.exception("Dropping repository_review table failed.") try: Component_table.drop() - except Exception as e: - print str(e) - log.debug("Dropping component table failed: %s" % str(e)) + except Exception: + log.exception("Dropping component table failed.") # Get the id of the REVIEWER group. cmd = "SELECT id FROM galaxy_group WHERE name = '%s';" % (IUC) row = migrate_engine.execute(cmd).fetchone() diff --git a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0014_add_deprecated_column.py b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0014_add_deprecated_column.py index 831d3ffdd7d..4967da8aa3a 100644 --- a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0014_add_deprecated_column.py +++ b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0014_add_deprecated_column.py @@ -1,6 +1,8 @@ """ Migration script to add the deprecated column to the repository table. """ +from __future__ import print_function + import logging import sys @@ -18,7 +20,7 @@ metadata = MetaData() def upgrade(migrate_engine): - print __doc__ + print(__doc__) metadata.bind = migrate_engine metadata.reflect() # Create and initialize imported column in job table. @@ -34,9 +36,8 @@ def upgrade(migrate_engine): elif migrate_engine.name in ['postgresql', 'postgres']: default_false = "false" migrate_engine.execute("UPDATE repository SET deprecated=%s" % default_false) - except Exception as e: - print "Adding deprecated column to the repository table failed: %s" % str(e) - log.debug("Adding deprecated column to the repository table failed: %s" % str(e)) + except Exception: + log.exception("Adding deprecated column to the repository table failed.") def downgrade(migrate_engine): @@ -46,6 +47,5 @@ def downgrade(migrate_engine): Repository_table = Table("repository", metadata, autoload=True) try: Repository_table.c.deprecated.drop() - except Exception as e: - print "Dropping column deprecated from the repository table failed: %s" % str(e) - log.debug("Dropping column deprecated from the repository table failed: %s" % str(e)) + except Exception: + log.exception("Dropping column deprecated from the repository table failed.") diff --git a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0015_add_api_keys_table.py b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0015_add_api_keys_table.py index 5e871d232e2..9527b2f5160 100644 --- a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0015_add_api_keys_table.py +++ b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0015_add_api_keys_table.py @@ -1,6 +1,8 @@ """ Migration script to add the api_keys table. """ +from __future__ import print_function + import datetime import logging import sys @@ -30,13 +32,13 @@ APIKeys_table = Table("api_keys", metadata, def upgrade(migrate_engine): - print __doc__ + print(__doc__) metadata.bind = migrate_engine metadata.reflect() try: APIKeys_table.create() - except Exception as e: - log.debug("Creating api_keys table failed: %s" % str(e)) + except Exception: + log.exception("Creating api_keys table failed.") def downgrade(migrate_engine): @@ -45,5 +47,5 @@ def downgrade(migrate_engine): metadata.reflect() try: APIKeys_table.drop() - except Exception as e: - log.debug("Dropping api_keys table failed: %s" % str(e)) + except Exception: + log.exception("Dropping api_keys table failed.") diff --git a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0016_add_do_not_test_tools_functionally_correct_errors_columns.py b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0016_add_do_not_test_tools_functionally_correct_errors_columns.py index 1ab9f615499..467b012ae17 100644 --- a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0016_add_do_not_test_tools_functionally_correct_errors_columns.py +++ b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0016_add_do_not_test_tools_functionally_correct_errors_columns.py @@ -1,6 +1,8 @@ """ Migration script to add the tool_test_errors, do_not_test, tools_functionally_correct, and time_last_tested columns to the repository_metadata table. """ +from __future__ import print_function + import logging import sys @@ -21,7 +23,7 @@ metadata = MetaData() def upgrade(migrate_engine): - print __doc__ + print(__doc__) metadata.bind = migrate_engine metadata.reflect() # Create and initialize tools_functionally_correct, do_not_test, time_last_tested, and tool_test_errors columns in repository_metadata table. @@ -37,9 +39,8 @@ def upgrade(migrate_engine): elif migrate_engine.name in ['postgresql', 'postgres']: default_false = "false" migrate_engine.execute("UPDATE repository_metadata SET tools_functionally_correct=%s" % default_false) - except Exception as e: - print "Adding tools_functionally_correct column to the repository_metadata table failed: %s" % str(e) - log.debug("Adding tools_functionally_correct column to the repository_metadata table failed: %s" % str(e)) + except Exception: + log.exception("Adding tools_functionally_correct column to the repository_metadata table failed.") c = Column("do_not_test", Boolean, default=False, index=True) try: # Create do_not_test column @@ -51,25 +52,22 @@ def upgrade(migrate_engine): elif migrate_engine.name in ['postgresql', 'postgres']: default_false = "false" migrate_engine.execute("UPDATE repository_metadata SET do_not_test=%s" % default_false) - except Exception as e: - print "Adding do_not_test column to the repository_metadata table failed: %s" % str(e) - log.debug("Adding do_not_test column to the repository_metadata table failed: %s" % str(e)) + except Exception: + log.exception("Adding do_not_test column to the repository_metadata table failed.") c = Column("time_last_tested", DateTime, default=None, nullable=True) try: # Create time_last_tested column c.create(RepositoryMetadata_table, index_name="ix_repository_metadata_tlt") assert c is RepositoryMetadata_table.c.time_last_tested - except Exception as e: - print "Adding time_last_tested column to the repository_metadata table failed: %s" % str(e) - log.debug("Adding time_last_tested column to the repository_metadata table failed: %s" % str(e)) + except Exception: + log.exception("Adding time_last_tested column to the repository_metadata table failed.") c = Column("tool_test_errors", JSONType, nullable=True) try: # Create tool_test_errors column c.create(RepositoryMetadata_table, index_name="ix_repository_metadata_tte") assert c is RepositoryMetadata_table.c.tool_test_errors - except Exception as e: - print "Adding tool_test_errors column to the repository_metadata table failed: %s" % str(e) - log.debug("Adding tool_test_errors column to the repository_metadata table failed: %s" % str(e)) + except Exception: + log.exception("Adding tool_test_errors column to the repository_metadata table failed.") def downgrade(migrate_engine): @@ -79,21 +77,17 @@ def downgrade(migrate_engine): RepositoryMetadata_table = Table("repository_metadata", metadata, autoload=True) try: RepositoryMetadata_table.c.tool_test_errors.drop() - except Exception as e: - print "Dropping column tool_test_errors from the repository_metadata table failed: %s" % str(e) - log.debug("Dropping column tool_test_errors from the repository_metadata table failed: %s" % str(e)) + except Exception: + log.exception("Dropping column tool_test_errors from the repository_metadata table failed.") try: RepositoryMetadata_table.c.time_last_tested.drop() - except Exception as e: - print "Dropping column time_last_tested from the repository_metadata table failed: %s" % str(e) - log.debug("Dropping column time_last_tested from the repository_metadata table failed: %s" % str(e)) + except Exception: + log.exception("Dropping column time_last_tested from the repository_metadata table failed.") try: RepositoryMetadata_table.c.do_not_test.drop() - except Exception as e: - print "Dropping column do_not_test from the repository_metadata table failed: %s" % str(e) - log.debug("Dropping column do_not_test from the repository_metadata table failed: %s" % str(e)) + except Exception: + log.exception("Dropping column do_not_test from the repository_metadata table failed.") try: RepositoryMetadata_table.c.tools_functionally_correct.drop() - except Exception as e: - print "Dropping column tools_functionally_correct from the repository_metadata table failed: %s" % str(e) - log.debug("Dropping column tools_functionally_correct from the repository_metadata table failed: %s" % str(e)) + except Exception: + log.exception("Dropping column tools_functionally_correct from the repository_metadata table failed.") diff --git a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0017_add_galaxy_utility_columns_to_repository_metadata_table.py b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0017_add_galaxy_utility_columns_to_repository_metadata_table.py index 3b5c0873960..b9be487b11d 100644 --- a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0017_add_galaxy_utility_columns_to_repository_metadata_table.py +++ b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0017_add_galaxy_utility_columns_to_repository_metadata_table.py @@ -2,6 +2,8 @@ Migration script to add the includes_datatypes, has_repository_dependencies, includes_tools, includes_tool_dependencies and includes_workflows columns to the repository_metadata table. """ +from __future__ import print_function + import logging import sys @@ -19,7 +21,7 @@ metadata = MetaData() def upgrade(migrate_engine): - print __doc__ + print(__doc__) metadata.bind = migrate_engine metadata.reflect() # Initialize. @@ -36,8 +38,8 @@ def upgrade(migrate_engine): c.create(RepositoryMetadata_table, index_name="ix_repository_metadata_inc_datatypes") assert c is RepositoryMetadata_table.c.includes_datatypes migrate_engine.execute("UPDATE repository_metadata SET includes_datatypes=%s" % default_false) - except Exception as e: - print "Adding includes_datatypes column to the repository_metadata table failed: %s" % str(e) + except Exception: + log.exception("Adding includes_datatypes column to the repository_metadata table failed.") # Create includes_datatypes column c = Column("has_repository_dependencies", Boolean, default=False, index=True) @@ -45,8 +47,8 @@ def upgrade(migrate_engine): c.create(RepositoryMetadata_table, index_name="ix_repository_metadata_has_repo_deps") assert c is RepositoryMetadata_table.c.has_repository_dependencies migrate_engine.execute("UPDATE repository_metadata SET has_repository_dependencies=%s" % default_false) - except Exception as e: - print "Adding has_repository_dependencies column to the repository_metadata table failed: %s" % str(e) + except Exception: + log.exception("Adding has_repository_dependencies column to the repository_metadata table failed.") # Create includes_tools column c = Column("includes_tools", Boolean, default=False, index=True) @@ -54,8 +56,8 @@ def upgrade(migrate_engine): c.create(RepositoryMetadata_table, index_name="ix_repository_metadata_inc_tools") assert c is RepositoryMetadata_table.c.includes_tools migrate_engine.execute("UPDATE repository_metadata SET includes_tools=%s" % default_false) - except Exception as e: - print "Adding includes_tools column to the repository_metadata table failed: %s" % str(e) + except Exception: + log.exception("Adding includes_tools column to the repository_metadata table failed.") # Create includes_tool_dependencies column c = Column("includes_tool_dependencies", Boolean, default=False, index=True) @@ -63,8 +65,8 @@ def upgrade(migrate_engine): c.create(RepositoryMetadata_table, index_name="ix_repository_metadata_inc_tool_deps") assert c is RepositoryMetadata_table.c.includes_tool_dependencies migrate_engine.execute("UPDATE repository_metadata SET includes_tool_dependencies=%s" % default_false) - except Exception as e: - print "Adding includes_tool_dependencies column to the repository_metadata table failed: %s" % str(e) + except Exception: + log.exception("Adding includes_tool_dependencies column to the repository_metadata table failed.") # Create includes_workflows column c = Column("includes_workflows", Boolean, default=False, index=True) @@ -72,8 +74,8 @@ def upgrade(migrate_engine): c.create(RepositoryMetadata_table, index_name="ix_repository_metadata_inc_workflows") assert c is RepositoryMetadata_table.c.includes_workflows migrate_engine.execute("UPDATE repository_metadata SET includes_workflows=%s" % default_false) - except Exception as e: - print "Adding includes_workflows column to the repository_metadata table failed: %s" % str(e) + except Exception: + log.exception("Adding includes_workflows column to the repository_metadata table failed.") def downgrade(migrate_engine): @@ -85,29 +87,29 @@ def downgrade(migrate_engine): # Drop the includes_workflows column. try: RepositoryMetadata_table.c.includes_workflows.drop() - except Exception as e: - print "Dropping column includes_workflows from the repository_metadata table failed: %s" % str(e) + except Exception: + log.exception("Dropping column includes_workflows from the repository_metadata table failed.") # Drop the includes_tool_dependencies column. try: RepositoryMetadata_table.c.includes_tool_dependencies.drop() - except Exception as e: - print "Dropping column includes_tool_dependencies from the repository_metadata table failed: %s" % str(e) + except Exception: + log.exception("Dropping column includes_tool_dependencies from the repository_metadata table failed.") # Drop the includes_tools column. try: RepositoryMetadata_table.c.includes_tools.drop() - except Exception as e: - print "Dropping column includes_tools from the repository_metadata table failed: %s" % str(e) + except Exception: + log.exception("Dropping column includes_tools from the repository_metadata table failed.") # Drop the has_repository_dependencies column. try: RepositoryMetadata_table.c.has_repository_dependencies.drop() - except Exception as e: - print "Dropping column has_repository_dependencies from the repository_metadata table failed: %s" % str(e) + except Exception: + log.exception("Dropping column has_repository_dependencies from the repository_metadata table failed.") # Drop the includes_datatypes column. try: RepositoryMetadata_table.c.includes_datatypes.drop() - except Exception as e: - print "Dropping column includes_datatypes from the repository_metadata table failed: %s" % str(e) + except Exception: + log.exception("Dropping column includes_datatypes from the repository_metadata table failed.") diff --git a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0018_add_repository_metadata_flag_columns.py b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0018_add_repository_metadata_flag_columns.py index 29692f63a75..b5c25263d44 100644 --- a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0018_add_repository_metadata_flag_columns.py +++ b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0018_add_repository_metadata_flag_columns.py @@ -2,6 +2,8 @@ Migration script to alter the repository_metadata table by dropping the tool_test_errors column and adding columns tool_test_results, missing_test_components. """ +from __future__ import print_function + import logging import sys @@ -23,7 +25,7 @@ metadata = MetaData() def upgrade(migrate_engine): - print __doc__ + print(__doc__) metadata.bind = migrate_engine metadata.reflect() # Initialize. @@ -44,16 +46,16 @@ def upgrade(migrate_engine): try: col = RepositoryMetadata_table.c.tool_test_errors col.drop() - except Exception as e: - log.debug("Dropping column 'tool_test_errors' from repository_metadata table failed: %s" % (str(e))) + except Exception: + log.exception("Dropping column 'tool_test_errors' from repository_metadata table failed.") # Create the tool_test_results column to replace the ill-named tool_test_errors column just dropped above. c = Column("tool_test_results", JSONType, nullable=True) try: c.create(RepositoryMetadata_table) assert c is RepositoryMetadata_table.c.tool_test_results - except Exception as e: - print "Adding tool_test_results column to the repository_metadata table failed: %s" % str(e) + except Exception: + log.exception("Adding tool_test_results column to the repository_metadata table failed.") # Create the missing_test_components column. c = Column("missing_test_components", Boolean, default=False, index=True) @@ -61,8 +63,8 @@ def upgrade(migrate_engine): c.create(RepositoryMetadata_table, index_name="ix_repository_metadata_mtc") assert c is RepositoryMetadata_table.c.missing_test_components migrate_engine.execute("UPDATE repository_metadata SET missing_test_components=%s" % default_false) - except Exception as e: - print "Adding missing_test_components column to the repository_metadata table failed: %s" % str(e) + except Exception: + log.exception("Adding missing_test_components column to the repository_metadata table failed.") def downgrade(migrate_engine): @@ -74,19 +76,19 @@ def downgrade(migrate_engine): # Drop the missing_test_components column. try: RepositoryMetadata_table.c.missing_test_components.drop() - except Exception as e: - print "Dropping column missing_test_components from the repository_metadata table failed: %s" % str(e) + except Exception: + log.exception("Dropping column missing_test_components from the repository_metadata table failed.") # Drop the tool_test_results column. try: RepositoryMetadata_table.c.tool_test_results.drop() - except Exception as e: - print "Dropping column tool_test_results from the repository_metadata table failed: %s" % str(e) + except Exception: + log.exception("Dropping column tool_test_results from the repository_metadata table failed.") # Create the tool_test_errors column. c = Column("tool_test_errors", JSONType, nullable=True) try: c.create(RepositoryMetadata_table) assert c is RepositoryMetadata_table.c.tool_test_errors - except Exception as e: - print "Adding tool_test_errors column to the repository_metadata table failed: %s" % str(e) + except Exception: + log.exception("Adding tool_test_errors column to the repository_metadata table failed.") diff --git a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0019_add_skip_tool_test_table_and_test_install_error_column.py b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0019_add_skip_tool_test_table_and_test_install_error_column.py index 66887751f39..622a988378a 100644 --- a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0019_add_skip_tool_test_table_and_test_install_error_column.py +++ b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0019_add_skip_tool_test_table_and_test_install_error_column.py @@ -1,6 +1,8 @@ """ Migration script to add the skip_tool_test table and add the test_install_error column to the repository_metadata table. """ +from __future__ import print_function + import datetime import logging import sys @@ -33,7 +35,7 @@ SkipToolTest_table = Table("skip_tool_test", metadata, def upgrade(migrate_engine): - print __doc__ + print(__doc__) metadata.bind = migrate_engine metadata.reflect() # Initialize. @@ -55,14 +57,14 @@ def upgrade(migrate_engine): c.create(RepositoryMetadata_table, index_name="ix_repository_metadata_ttie") assert c is RepositoryMetadata_table.c.test_install_error migrate_engine.execute("UPDATE repository_metadata SET test_install_error=%s" % default_false) - except Exception as e: - print "Adding test_install_error column to the repository_metadata table failed: %s" % str(e) + except Exception: + log.exception("Adding test_install_error column to the repository_metadata table failed.") # Create skip_tool_test table. try: SkipToolTest_table.create() - except Exception as e: - print "Creating the skip_tool_test table failed: %s" % str(e) + except Exception: + log.exception("Creating the skip_tool_test table failed.") def downgrade(migrate_engine): @@ -72,12 +74,12 @@ def downgrade(migrate_engine): # Drop the skip_tool_test table. try: SkipToolTest_table.drop() - except Exception as e: - print "Dropping the skip_tool_test table failed: %s" % str(e) + except Exception: + log.exception("Dropping the skip_tool_test table failed.") # Drop test_install_error column from the repository_metadata table. RepositoryMetadata_table = Table("repository_metadata", metadata, autoload=True) try: RepositoryMetadata_table.c.test_install_error.drop() - except Exception as e: - print "Dropping column test_install_error from the repository_metadata table failed: %s" % str(e) + except Exception: + log.exception("Dropping column test_install_error from the repository_metadata table failed.") diff --git a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0020_add_repository_type_column.py b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0020_add_repository_type_column.py index 2a11e54fcda..1488dafbb6a 100644 --- a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0020_add_repository_type_column.py +++ b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0020_add_repository_type_column.py @@ -1,4 +1,6 @@ """Migration script to add the type column to the repository table.""" +from __future__ import print_function + import logging import sys @@ -19,7 +21,7 @@ metadata = MetaData() def upgrade(migrate_engine): - print __doc__ + print(__doc__) metadata.bind = migrate_engine metadata.reflect() Repository_table = Table("repository", metadata, autoload=True) @@ -28,8 +30,8 @@ def upgrade(migrate_engine): # Create c.create(Repository_table, index_name="ix_repository_type") assert c is Repository_table.c.type - except Exception as e: - print "Adding type column to the repository table failed: %s" % str(e) + except Exception: + log.exception("Adding type column to the repository table failed.") # Update the type column to have the default unrestricted value. cmd = "UPDATE repository SET type = 'unrestricted'" migrate_engine.execute(cmd) @@ -42,5 +44,5 @@ def downgrade(migrate_engine): Repository_table = Table("repository", metadata, autoload=True) try: Repository_table.c.type.drop() - except Exception as e: - print "Dropping column type from the repository table failed: %s" % str(e) + except Exception: + log.exception("Dropping column type from the repository table failed.") diff --git a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0021_change_repository_type_value.py b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0021_change_repository_type_value.py index 3b58502accd..279b451aba4 100644 --- a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0021_change_repository_type_value.py +++ b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0021_change_repository_type_value.py @@ -1,4 +1,6 @@ """Migration script to change repository.type column value from generic to unrestricted.""" +from __future__ import print_function + import logging import sys @@ -16,7 +18,7 @@ metadata = MetaData() def upgrade(migrate_engine): - print __doc__ + print(__doc__) metadata.bind = migrate_engine metadata.reflect() # Update the type column to have the default unrestricted value. diff --git a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0022_add_repository_admin_roles.py b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0022_add_repository_admin_roles.py index fa918b6739d..c4c0bafb836 100644 --- a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0022_add_repository_admin_roles.py +++ b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0022_add_repository_admin_roles.py @@ -3,6 +3,8 @@ Migration script to create the repository_role_association table, insert name-sp repository administrative roles into the role table and associate each repository and owner with the appropriate name-spaced role. """ +from __future__ import print_function + import datetime import logging import sys @@ -59,15 +61,14 @@ def boolean_false(migrate_engine): def upgrade(migrate_engine): - print __doc__ + print(__doc__) metadata.bind = migrate_engine metadata.reflect() # Create the new repository_role_association table. try: RepositoryRoleAssociation_table.create() - except Exception as e: - print str(e) - log.debug("Creating repository_role_association table failed: %s" % str(e)) + except Exception: + log.exception("Creating repository_role_association table failed.") # Select the list of repositories and associated public user names for their owners. user_ids = [] repository_ids = [] @@ -159,5 +160,5 @@ def downgrade(migrate_engine): log.debug("Failed loading table repository_role_association") try: RepositoryRoleAssociation_table.drop() - except Exception as e: - log.debug("Dropping repository_role_association table failed: %s" % str(e)) + except Exception: + log.exception("Dropping repository_role_association table failed.") diff --git a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0023_add_repository_url_and_hompeage_url.py b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0023_add_repository_url_and_hompeage_url.py index 698f5d0fca4..66f1af1e161 100644 --- a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0023_add_repository_url_and_hompeage_url.py +++ b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0023_add_repository_url_and_hompeage_url.py @@ -2,6 +2,8 @@ Migration script to add the remote_repository_url and homepage_url columns to the repository table. """ +from __future__ import print_function + import logging import sys @@ -21,7 +23,7 @@ metadata = MetaData() def upgrade(migrate_engine): - print __doc__ + print(__doc__) metadata.bind = migrate_engine metadata.reflect() Repository_table = Table("repository", metadata, autoload=True) @@ -33,8 +35,8 @@ def upgrade(migrate_engine): c_homepage.create(Repository_table) assert c_remote is Repository_table.c.remote_repository_url assert c_homepage is Repository_table.c.homepage_url - except Exception as e: - print "Adding remote_repository_url and homepage_url columns to the repository table failed: %s" % str(e) + except Exception: + log.exception("Adding remote_repository_url and homepage_url columns to the repository table failed.") def downgrade(migrate_engine): @@ -45,5 +47,5 @@ def downgrade(migrate_engine): try: Repository_table.c.remote_repository_url.drop() Repository_table.c.homepage_url.drop() - except Exception as e: - print "Dropping columns remote_repository_url and homepage_url from the repository table failed: %s" % str(e) + except Exception: + log.exception("Dropping columns remote_repository_url and homepage_url from the repository table failed.") diff --git a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0024_password_reset.py b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0024_password_reset.py index 01993922d7b..008355c78c8 100644 --- a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0024_password_reset.py +++ b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0024_password_reset.py @@ -1,6 +1,8 @@ """ Migration script for the password reset table """ +from __future__ import print_function + import datetime import logging @@ -18,12 +20,11 @@ PasswordResetToken_table = Table("password_reset_token", metadata, def upgrade(migrate_engine): metadata.bind = migrate_engine - print __doc__ + print(__doc__) metadata.reflect() try: PasswordResetToken_table.create() - except Exception as e: - print str(e) + except Exception: log.exception("Creating %s table failed", PasswordResetToken_table.name) @@ -32,6 +33,5 @@ def downgrade(migrate_engine): metadata.reflect() try: PasswordResetToken_table.drop() - except Exception as e: - print str(e) + except Exception: log.exception("Dropping %s table failed", PasswordResetToken_table.name) diff --git a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0025_session_timeout.py b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0025_session_timeout.py index d854a02bb41..8e5a1b04518 100644 --- a/lib/galaxy/webapps/tool_shed/model/migrate/versions/0025_session_timeout.py +++ b/lib/galaxy/webapps/tool_shed/model/migrate/versions/0025_session_timeout.py @@ -1,6 +1,8 @@ """ Migration script to add session update time (used for timeouts) """ +from __future__ import print_function + import datetime import logging @@ -13,7 +15,7 @@ metadata = MetaData() def upgrade(migrate_engine): metadata.bind = migrate_engine - print __doc__ + print(__doc__) metadata.reflect() lastaction_column = Column("last_action", DateTime) @@ -31,8 +33,7 @@ def __add_column(column, table_name, metadata, **kwds): try: table = Table(table_name, metadata, autoload=True) column.create(table, **kwds) - except Exception as e: - print str(e) + except Exception: log.exception("Adding column %s failed.", column) @@ -40,6 +41,5 @@ def __drop_column(column_name, table_name, metadata): try: table = Table(table_name, metadata, autoload=True) getattr(table.c, column_name).drop() - except Exception as e: - print str(e) + except Exception: log.exception("Dropping column %s failed.", column_name) diff --git a/lib/tool_shed/galaxy_install/tool_dependencies/recipe/step_handler.py b/lib/tool_shed/galaxy_install/tool_dependencies/recipe/step_handler.py index ff1ce4794f5..ceb271b06ae 100644 --- a/lib/tool_shed/galaxy_install/tool_dependencies/recipe/step_handler.py +++ b/lib/tool_shed/galaxy_install/tool_dependencies/recipe/step_handler.py @@ -1807,7 +1807,7 @@ class SetupVirtualEnv(Download, RecipeStep): # to subprocess.Popen. for site_packages_command in [r"""%s -c 'import site; site.getsitepackages()[0]'""" % os.path.join(venv_directory, "bin", "python"), - r"""%s -c 'import os, sys; print os.path.join( sys.prefix, "lib", "python" + sys.version[:3], "site-packages" )'""" % + r"""%s -c 'from __future__ import print_function; import os, sys; print(os.path.join(sys.prefix, "lib", "python" + sys.version[:3], "site-packages"))'""" % os.path.join(venv_directory, "bin", "python")]: output = install_environment.handle_command(tool_dependency=tool_dependency, cmd=site_packages_command, diff --git a/scripts/api/copy_hda_to_library_folder.py b/scripts/api/copy_hda_to_library_folder.py index 01e63fa8003..8a967b3751c 100755 --- a/scripts/api/copy_hda_to_library_folder.py +++ b/scripts/api/copy_hda_to_library_folder.py @@ -1,4 +1,6 @@ #!/usr/bin/env python +from __future__ import print_function + import sys from common import submit @@ -22,7 +24,7 @@ def copy_hda_to_library_folder(base_url, key, hda_id, library_id, folder_id, mes if __name__ == '__main__': num_args = len(sys.argv) if num_args < 6: - print >> sys.stderr, usage + print(usage, file=sys.stderr) sys.exit(1) (base_url, key, hda_id, library_id, folder_id) = sys.argv[1:6] @@ -31,5 +33,5 @@ if __name__ == '__main__': if num_args >= 7: message = sys.argv[6] - print >> sys.stderr, base_url, key, hda_id, library_id, folder_id, message + print(base_url, key, hda_id, library_id, folder_id, message, file=sys.stderr) returned = copy_hda_to_library_folder(base_url, key, hda_id, library_id, folder_id, message) diff --git a/scripts/api/library_upload_dir.py b/scripts/api/library_upload_dir.py index ff293cebb4e..84d321d6fc4 100644 --- a/scripts/api/library_upload_dir.py +++ b/scripts/api/library_upload_dir.py @@ -1,4 +1,6 @@ #!/usr/bin/env python +from __future__ import print_function + import argparse import os import sys @@ -66,14 +68,11 @@ class Uploader: fk = '/'.join(path_parts) if fk in self.memo_path: - # print "Cache hit %s" % fk return self.memo_path[fk] else: - # print "Cache miss %s" % fk for i in reversed(range(len(path_parts))): fk = '/'.join(path_parts[0:i + 1]) if fk in self.memo_path: - # print "Parent folder hit %s" % fk dropped_prefix = path_parts[0:i + 1] path_parts = path_parts[i + 1:] base_folder = self.memo_path[fk] @@ -84,7 +83,7 @@ class Uploader: nfk.append('/'.join(list(dropped_prefix) + list(path_parts[0:i + 1]))) # Recursively create the path from our base_folder starting points, - # gettting the IDs of each folder per path component + # getting the IDs of each folder per path component ids = self.recursively_build_path(path_parts, base_folder) # These are then associated with the paths. @@ -102,7 +101,6 @@ class Uploader: else: pf = self.gi.libraries.create_folder(self.library_id, path_parts[0], base_folder_id=parent_folder_id) ids.append(pf[0]['id']) - # print "create_folder(%s, %s, %s) = %s" % (self.library_id, path_parts[0], parent_folder_id, pf[0]['id']) return self.recursively_build_path(path_parts[1:], pf[0]['id'], ids=ids) # http://stackoverflow.com/questions/13505819/python-split-path-recursively/13505966#13505966 diff --git a/scripts/api/workflow_import.py b/scripts/api/workflow_import.py index 5faf118f36d..8412e5dfee3 100755 --- a/scripts/api/workflow_import.py +++ b/scripts/api/workflow_import.py @@ -24,7 +24,6 @@ def main(): except IndexError: print('usage: %s key galaxy_url workflow_file' % os.path.basename(sys.argv[0])) sys.exit(1) - # print display( api_key, api_base_url + "/api/workflows" ) submit(api_key, api_url, data, return_formatted=False) diff --git a/scripts/cleanup_datasets/admin_cleanup_datasets.py b/scripts/cleanup_datasets/admin_cleanup_datasets.py index cee5d7916f3..c5d92e93897 100755 --- a/scripts/cleanup_datasets/admin_cleanup_datasets.py +++ b/scripts/cleanup_datasets/admin_cleanup_datasets.py @@ -63,7 +63,7 @@ log = logging.getLogger() log.setLevel(logging.INFO) log.addHandler(logging.StreamHandler(sys.stdout)) -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) def main(): diff --git a/scripts/cleanup_datasets/cleanup_datasets.py b/scripts/cleanup_datasets/cleanup_datasets.py index a3a6bdaf8ec..a4257138e95 100755 --- a/scripts/cleanup_datasets/cleanup_datasets.py +++ b/scripts/cleanup_datasets/cleanup_datasets.py @@ -27,7 +27,7 @@ log = logging.getLogger() log.setLevel(logging.INFO) log.addHandler(logging.StreamHandler(sys.stdout)) -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) def main(): diff --git a/scripts/cleanup_datasets/populate_uuid.py b/scripts/cleanup_datasets/populate_uuid.py index 316ee7886a9..fe9c391509c 100755 --- a/scripts/cleanup_datasets/populate_uuid.py +++ b/scripts/cleanup_datasets/populate_uuid.py @@ -14,7 +14,7 @@ import uuid from galaxy.model import mapping from galaxy.model.orm.scripts import get_config -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) def usage(prog): diff --git a/scripts/cleanup_datasets/remove_renamed_datasets_from_disk.py b/scripts/cleanup_datasets/remove_renamed_datasets_from_disk.py index 7ca27cae418..2ce9089e4ad 100755 --- a/scripts/cleanup_datasets/remove_renamed_datasets_from_disk.py +++ b/scripts/cleanup_datasets/remove_renamed_datasets_from_disk.py @@ -8,7 +8,7 @@ from __future__ import print_function import os import sys -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) def usage(prog): diff --git a/scripts/cleanup_datasets/rename_purged_datasets.py b/scripts/cleanup_datasets/rename_purged_datasets.py index 95b4d5a5576..e4c18563025 100755 --- a/scripts/cleanup_datasets/rename_purged_datasets.py +++ b/scripts/cleanup_datasets/rename_purged_datasets.py @@ -8,7 +8,7 @@ from __future__ import print_function import os import sys -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) def usage(prog): diff --git a/scripts/cleanup_datasets/update_dataset_size.py b/scripts/cleanup_datasets/update_dataset_size.py index 177c4cb8337..5cebec6e20e 100755 --- a/scripts/cleanup_datasets/update_dataset_size.py +++ b/scripts/cleanup_datasets/update_dataset_size.py @@ -12,7 +12,7 @@ from six.moves import configparser import galaxy.app -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) def usage(prog): diff --git a/scripts/cleanup_datasets/update_metadata.py b/scripts/cleanup_datasets/update_metadata.py index a63f93d287c..e9ead895468 100755 --- a/scripts/cleanup_datasets/update_metadata.py +++ b/scripts/cleanup_datasets/update_metadata.py @@ -17,7 +17,7 @@ sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pa import galaxy.app import galaxy.datatypes.tabular -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) def usage(prog): diff --git a/scripts/db_shell.py b/scripts/db_shell.py index 4a7519525b6..f7e10d61086 100644 --- a/scripts/db_shell.py +++ b/scripts/db_shell.py @@ -41,7 +41,7 @@ sa_session = init('/tmp/', db_url).context # http://stackoverflow.com/questions/5631078/sqlalchemy-print-the-actual-query def printquery(statement, bind=None): """ - print a query, with values filled in + Print a query, with values filled in for debugging purposes *only* for security, you should always separate queries from their values please also note that this function is quite slow diff --git a/scripts/extract_toolbox_sections.py b/scripts/extract_toolbox_sections.py index 57048b8d07e..cc0a49bd28d 100644 --- a/scripts/extract_toolbox_sections.py +++ b/scripts/extract_toolbox_sections.py @@ -123,9 +123,8 @@ def getfnl(startdir): if fn.endswith('.xml'): try: doc = ET.parse(fullfn) - except: - print "Oops, bad xml in: ", fullfn - raise + except Exception as e: + raise Exception("Oops, bad XML in '%s': %s" % (fullfn, e)) rootelement = doc.getroot() # here we check if this xml file actually is a tool conf xml! if rootelement.tag == 'tool': diff --git a/scripts/get_platforms.py b/scripts/get_platforms.py index 8f88d6ff925..b585da28690 100755 --- a/scripts/get_platforms.py +++ b/scripts/get_platforms.py @@ -1,11 +1,13 @@ #!/usr/bin/env python +from __future__ import print_function + import os import sys -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) lib = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, "lib")) sys.path.insert(1, lib) import pkg_resources -print pkg_resources.get_platform() +print(pkg_resources.get_platform()) diff --git a/scripts/helper.py b/scripts/helper.py index 0257950dce0..0e287f90c45 100644 --- a/scripts/helper.py +++ b/scripts/helper.py @@ -4,6 +4,8 @@ A command line helper for common operations performed by Galaxy maintainers. Encodes and decodes IDs, returns Dataset IDs if provided an HDA or LDDA id, returns the disk path of a dataset. """ +from __future__ import print_function + import os import sys from ConfigParser import ConfigParser @@ -41,10 +43,10 @@ helper = security.SecurityHelper(id_secret=config.get('app:main', 'id_secret')) model = mapping.init(config.get('app:main', 'file_path'), config.get('app:main', 'database_connection'), create_tables=False) if options.encode_id: - print 'Encoded "%s": %s' % (options.encode_id, helper.encode_id(options.encode_id)) + print('Encoded "%s": %s' % (options.encode_id, helper.encode_id(options.encode_id))) if options.decode_id: - print 'Decoded "%s": %s' % (options.decode_id, helper.decode_id(options.decode_id)) + print('Decoded "%s": %s' % (options.decode_id, helper.decode_id(options.decode_id))) if options.hda_id: try: @@ -52,7 +54,7 @@ if options.hda_id: except: hda_id = int(helper.decode_id(options.hda_id)) hda = model.context.current.query(model.HistoryDatasetAssociation).get(hda_id) - print 'HDA "%s" is Dataset "%s" at: %s' % (hda.id, hda.dataset.id, hda.file_name) + print('HDA "%s" is Dataset "%s" at: %s' % (hda.id, hda.dataset.id, hda.file_name)) if options.ldda_id: try: @@ -60,4 +62,4 @@ if options.ldda_id: except: ldda_id = int(helper.decode_id(options.ldda_id)) ldda = model.context.current.query(model.HistoryDatasetAssociation).get(ldda_id) - print 'LDDA "%s" is Dataset "%s" at: %s' % (ldda.id, ldda.dataset.id, ldda.file_name) + print('LDDA "%s" is Dataset "%s" at: %s' % (ldda.id, ldda.dataset.id, ldda.file_name)) diff --git a/scripts/loc_files/create_all_fasta_loc.py b/scripts/loc_files/create_all_fasta_loc.py index 6f2e7173565..badb03d27e9 100644 --- a/scripts/loc_files/create_all_fasta_loc.py +++ b/scripts/loc_files/create_all_fasta_loc.py @@ -23,6 +23,8 @@ usage: %prog [options] -a, --append=a: Append to existing all_fasta.loc file rather than create new -p, --sample-text=p: Copy over text from all_fasta.loc.sample file (false if set to append) """ +from __future__ import print_function + import optparse import os import sys @@ -199,16 +201,16 @@ def __main__(): paths_to_look_in = [os.path.join(options.genome_dir, '%s')] # say what we're looking in - print '\nLooking in:\n\t%s' % '\n\t'.join([p % '' for p in paths_to_look_in]) + print('\nLooking in:\n\t%s' % '\n\t'.join(p % '' for p in paths_to_look_in)) poss_names = ['%s' % _ for _ in variants] - print 'for files that are named %s' % ', '.join(poss_names[:-1]), + print('for files that are named %s' % ', '.join(poss_names[:-1]), end=' ') if len(poss_names) > 1: - print 'or %s' % poss_names[-1], + print('or %s' % poss_names[-1], end=' ') if len(options.fasta_exts) == 1: - print 'with the extension %s.' % ', '.join(fasta_exts[:-1]) + print('with the extension %s.' % ', '.join(fasta_exts[:-1])) else: - print 'with the extension %s or %s.' % (', '.join(fasta_exts[:-1]), fasta_exts[-1]) - print '\nSkipping the following:\n\t%s' % '\n\t'.join(exemptions) + print('with the extension %s or %s.' % (', '.join(fasta_exts[:-1]), fasta_exts[-1])) + print('\nSkipping the following:\n\t%s' % '\n\t'.join(exemptions)) # get column names col_values = [] @@ -265,8 +267,8 @@ def __main__(): del fasta_locs[tr] # output results - print '\nThere were %s fasta files found that were not included because they did not have the expected file names.' % len(unmatching_fasta_paths) - print '%s fasta files were found and listed.\n' % len(fasta_locs.keys()) + print('\nThere were %s fasta files found that were not included because they did not have the expected file names.' % len(unmatching_fasta_paths)) + print('%s fasta files were found and listed.\n' % len(fasta_locs.keys())) # output unmatching fasta files if options.unmatching_fasta and unmatching_fasta_paths: diff --git a/scripts/manage_tools.py b/scripts/manage_tools.py index 23522e8a517..fafc9c6e2be 100644 --- a/scripts/manage_tools.py +++ b/scripts/manage_tools.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import logging import os.path import sys @@ -14,7 +16,7 @@ log = logging.getLogger(__name__) config_file = read_config_file_arg(sys.argv, 'config/galaxy.ini', 'universe_wsgi.ini') if not os.path.exists(config_file): - print "Galaxy config file does not exist (hint: use '-c config.ini' for non-standard locations): %s" % config_file + print("Galaxy config file does not exist (hint: use '-c config.ini' for non-standard locations): %s" % config_file) sys.exit(1) repo = 'lib/tool_shed/galaxy_install/migrate' diff --git a/scripts/metagenomics/convert_title.py b/scripts/metagenomics/convert_title.py index 64c0ff86819..2bff2d10907 100644 --- a/scripts/metagenomics/convert_title.py +++ b/scripts/metagenomics/convert_title.py @@ -1,9 +1,9 @@ #!/usr/bin/env python - """ convert nt and wgs data (fasta format) to giNumber_seqLen run formatdb in the command line: gunzip -c nt.gz |formatdb -i stdin -p F -n "nt.chunk" -v 2000 """ +from __future__ import print_function import sys @@ -19,8 +19,8 @@ if __name__ == '__main__': if len_seq > 0: if gi is None: raise Exception('The first sequence does not have an header.') - print ">%s_%d" % (gi, len_seq) - print "\n".join(seq) + print(">%s_%d" % (gi, len_seq)) + print("\n".join(seq)) title = line fields = title.split('|') if len(fields) >= 2 and fields[0] == '>gi': @@ -34,7 +34,7 @@ if __name__ == '__main__': seq.append(line) len_seq += len(line) if len_seq > 0: - print ">%s_%d" % (gi, len_seq) - print "\n".join(seq) + print(">%s_%d" % (gi, len_seq)) + print("\n".join(seq)) - print >> sys.stderr, "Unable to find gi number for %d sequences, the title is replaced as giunknown" % (invalid_lines) + print("Unable to find gi number for %d sequences, the title is replaced as giunknown" % (invalid_lines), file=sys.stderr) diff --git a/scripts/microbes/BeautifulSoup.py b/scripts/microbes/BeautifulSoup.py index b9262d7a828..dccc77af9ea 100644 --- a/scripts/microbes/BeautifulSoup.py +++ b/scripts/microbes/BeautifulSoup.py @@ -42,6 +42,7 @@ documentation: http://www.crummy.com/software/BeautifulSoup/documentation.html """ from __future__ import generators +from __future__ import print_function import codecs import re @@ -1807,4 +1808,4 @@ class UnicodeDammit: # By default, act as an HTML pretty-printer. if __name__ == '__main__': soup = BeautifulSoup(sys.stdin.read()) - print soup.prettify() + print(soup.prettify()) diff --git a/scripts/microbes/create_bacteria_loc_file.py b/scripts/microbes/create_bacteria_loc_file.py index 601b6120805..4eac7698ea0 100644 --- a/scripts/microbes/create_bacteria_loc_file.py +++ b/scripts/microbes/create_bacteria_loc_file.py @@ -1,9 +1,11 @@ #!/usr/bin/env python # Dan Blankenberg +from __future__ import print_function + import os import sys -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) def __main__(): @@ -12,7 +14,6 @@ def __main__(): base_dir = sys.argv[1] except: pass - # print "using default base_dir:", base_dir organisms = {} for result in os.walk(base_dir): @@ -47,26 +48,26 @@ def __main__(): continue if 'build' in org: build = org['build'] - print "ORG\t%s\t%s\t%s\t%s\t%s\t%s\tUCSC" % (build, org['name'], org['kingdom'], org['group'], org['chromosomes'], org['info url']) + print("ORG\t%s\t%s\t%s\t%s\t%s\t%s\tUCSC" % (build, org['name'], org['kingdom'], org['group'], org['chromosomes'], org['info url'])) else: - print "ORG\t%s\t%s\t%s\t%s\t%s\t%s\tNone" % (build, org['name'], org['kingdom'], org['group'], org['chromosomes'], org['info url']) + print("ORG\t%s\t%s\t%s\t%s\t%s\t%s\tNone" % (build, org['name'], org['kingdom'], org['group'], org['chromosomes'], org['info url'])) for chr in org['chrs']: chr = org['chrs'][chr] - print "CHR\t%s\t%s\t%s\t%s\t%s\t%s\t%s" % (build, chr['chromosome'], chr['name'], chr['length'], chr['gi'], chr['gb'], "http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?db=nucleotide&val=" + chr['refseq']) + print("CHR\t%s\t%s\t%s\t%s\t%s\t%s\t%s" % (build, chr['chromosome'], chr['name'], chr['length'], chr['gi'], chr['gb'], "http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?db=nucleotide&val=" + chr['refseq'])) for feature in ['CDS', 'tRNA', 'rRNA']: - print "DATA\t%s_%s_%s\t%s\t%s\t%s\t%s\t%s" % (build, chr['chromosome'], feature, build, chr['chromosome'], feature, "bed", os.path.join(org['base_dir'], "%s.%s.bed" % (chr['chromosome'], feature))) + print("DATA\t%s_%s_%s\t%s\t%s\t%s\t%s\t%s" % (build, chr['chromosome'], feature, build, chr['chromosome'], feature, "bed", os.path.join(org['base_dir'], "%s.%s.bed" % (chr['chromosome'], feature)))) # FASTA - print "DATA\t%s_%s_%s\t%s\t%s\t%s\t%s\t%s" % (build, chr['chromosome'], "seq", build, chr['chromosome'], "sequence", "fasta", os.path.join(org['base_dir'], "%s.fna" % chr['chromosome'])) + print("DATA\t%s_%s_%s\t%s\t%s\t%s\t%s\t%s" % (build, chr['chromosome'], "seq", build, chr['chromosome'], "sequence", "fasta", os.path.join(org['base_dir'], "%s.fna" % chr['chromosome']))) # GeneMark if os.path.exists(os.path.join(org['base_dir'], "%s.GeneMark.bed" % chr['chromosome'])): - print "DATA\t%s_%s_%s\t%s\t%s\t%s\t%s\t%s" % (build, chr['chromosome'], "GeneMark", build, chr['chromosome'], "GeneMark", "bed", os.path.join(org['base_dir'], "%s.GeneMark.bed" % chr['chromosome'])) + print("DATA\t%s_%s_%s\t%s\t%s\t%s\t%s\t%s" % (build, chr['chromosome'], "GeneMark", build, chr['chromosome'], "GeneMark", "bed", os.path.join(org['base_dir'], "%s.GeneMark.bed" % chr['chromosome']))) # GenMarkHMM if os.path.exists(os.path.join(org['base_dir'], "%s.GeneMarkHMM.bed" % chr['chromosome'])): - print "DATA\t%s_%s_%s\t%s\t%s\t%s\t%s\t%s" % (build, chr['chromosome'], "GeneMarkHMM", build, chr['chromosome'], "GeneMarkHMM", "bed", os.path.join(org['base_dir'], "%s.GeneMarkHMM.bed" % chr['chromosome'])) + print("DATA\t%s_%s_%s\t%s\t%s\t%s\t%s\t%s" % (build, chr['chromosome'], "GeneMarkHMM", build, chr['chromosome'], "GeneMarkHMM", "bed", os.path.join(org['base_dir'], "%s.GeneMarkHMM.bed" % chr['chromosome']))) # Glimmer3 if os.path.exists(os.path.join(org['base_dir'], "%s.Glimmer3.bed" % chr['chromosome'])): - print "DATA\t%s_%s_%s\t%s\t%s\t%s\t%s\t%s" % (build, chr['chromosome'], "Glimmer3", build, chr['chromosome'], "Glimmer3", "bed", os.path.join(org['base_dir'], "%s.Glimmer3.bed" % chr['chromosome'])) + print("DATA\t%s_%s_%s\t%s\t%s\t%s\t%s\t%s" % (build, chr['chromosome'], "Glimmer3", build, chr['chromosome'], "Glimmer3", "bed", os.path.join(org['base_dir'], "%s.Glimmer3.bed" % chr['chromosome']))) if __name__ == "__main__": diff --git a/scripts/microbes/create_bacteria_table.py b/scripts/microbes/create_bacteria_table.py index 4cde20fba45..5c117f78228 100644 --- a/scripts/microbes/create_bacteria_table.py +++ b/scripts/microbes/create_bacteria_table.py @@ -1,9 +1,11 @@ #!/usr/bin/env python # Dan Blankenberg +from __future__ import print_function + import os import sys -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) def __main__(): @@ -12,7 +14,6 @@ def __main__(): base_dir = sys.argv[1] except: pass - # print "using default base_dir:", base_dir organisms = {} for result in os.walk(base_dir): @@ -55,7 +56,7 @@ def __main__(): if swap_test is False: break - print "||'''Organism'''||'''Kingdom'''||'''Group'''||'''Links to UCSC Archaea Browser'''||" + print("||'''Organism'''||'''Kingdom'''||'''Group'''||'''Links to UCSC Archaea Browser'''||") for org in orgs: org = organisms[org] @@ -72,7 +73,7 @@ def __main__(): if at_ucsc: out_str = out_str + "Yes" out_str = out_str + "||" - print out_str + print(out_str) if __name__ == "__main__": diff --git a/scripts/microbes/create_nib_seq_loc_file.py b/scripts/microbes/create_nib_seq_loc_file.py index 39d9b76ffeb..b3a53c398bc 100644 --- a/scripts/microbes/create_nib_seq_loc_file.py +++ b/scripts/microbes/create_nib_seq_loc_file.py @@ -1,9 +1,11 @@ #!/usr/bin/env python # Dan Blankenberg +from __future__ import print_function + import os import sys -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) def __main__(): @@ -11,13 +13,13 @@ def __main__(): try: base_dir = sys.argv[1] except: - print "using default base_dir:", base_dir + print("using default base_dir:", base_dir) loc_out = os.path.join(base_dir, "seq.loc") try: loc_out = os.path.join(base_dir, sys.argv[2]) except: - print "using default seq.loc:", loc_out + print("using default seq.loc:", loc_out) organisms = {} @@ -63,12 +65,12 @@ def __main__(): try: os.mkdir(seq_path) except: - print "Skipping", build + print("Skipping", build) # continue loc_out.write("seq %s %s\n" % (build, seq_path)) - # print org info + # Print org info for chr in org['chrs']: chr = org['chrs'][chr] diff --git a/scripts/microbes/get_builds_lengths.py b/scripts/microbes/get_builds_lengths.py index f4c9a007225..6c311c1b27f 100644 --- a/scripts/microbes/get_builds_lengths.py +++ b/scripts/microbes/get_builds_lengths.py @@ -1,9 +1,11 @@ #!/usr/bin/env python # Dan Blankenberg +from __future__ import print_function + import os import sys -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) def __main__(): @@ -12,7 +14,6 @@ def __main__(): base_dir = sys.argv[1] except: pass - # print "using default base_dir:", base_dir organisms = {} for result in os.walk(base_dir): @@ -53,7 +54,7 @@ def __main__(): for chrom in org['chrs']: chrom = org['chrs'][chrom] chrs.append("%s=%s" % (chrom['chromosome'], chrom['length'])) - print "%s\t%s\t%s" % (build, org['name'], ",".join(chrs)) + print("%s\t%s\t%s" % (build, org['name'], ",".join(chrs))) if __name__ == "__main__": diff --git a/scripts/microbes/harvest_bacteria.py b/scripts/microbes/harvest_bacteria.py index 762d9cfa821..f30cf820968 100644 --- a/scripts/microbes/harvest_bacteria.py +++ b/scripts/microbes/harvest_bacteria.py @@ -4,6 +4,8 @@ # Harvest Bacteria # Connects to NCBI's Microbial Genome Projects website and scrapes it for information. # Downloads and converts annotations for each Genome +from __future__ import print_function + import os import sys import time @@ -19,7 +21,7 @@ from util import ( get_bed_from_glimmer3 ) -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) # this defines the types of ftp files we are interested in, and how to process/convert them to a form for our use desired_ftp_files = {'GeneMark': {'ext': 'GeneMark-2.5f', 'parser': 'process_GeneMark'}, @@ -55,7 +57,7 @@ def iter_genome_projects(url="http://www.ncbi.nlm.nih.gov/genomes/lproks.cgi?vie try: ftp_url = fields[22].split("href=\"")[1].split("\"")[0] except: - print "FAILED TO AQUIRE FTP ADDRESS:", org_num, info_url + print("FAILED TO AQUIRE FTP ADDRESS:", org_num, info_url) ftp_url = None chroms = get_chroms_by_project_id(org_num) @@ -72,7 +74,7 @@ def get_chroms_by_project_id(org_num, base_url="http://www.ncbi.nlm.nih.gov/entr try: html = requests.get(url).text except: - print "GENOME PROJECT FAILED:", html_count, "org:", org_num, url + print("GENOME PROJECT FAILED:", html_count, "org:", org_num, url) html = None time.sleep(1) # Throttle Connection if html is None: @@ -131,7 +133,7 @@ def scrape_ftp(ftp_contents, org_dir, org_num, refseq, ftp_url): if items['parser'] is not None: globals()[items['parser']](target_filename, org_num, refseq) else: - print "FTP filetype:", file_type, "not found for", org_num, refseq + print("FTP filetype:", file_type, "not found for", org_num, refseq) # FTP Files have been Loaded @@ -169,14 +171,14 @@ def process_Genbank(filename, org_num, refseq): feature_file = open(os.path.join(os.path.split(filename)[0], "%s.%s.bed" % (refseq, feature)), 'wb+') feature_file.write('\n'.join(features[feature])) feature_file.close() - print "Genbank extraction finished for chrom:", refseq, "file:", filename + print("Genbank extraction finished for chrom:", refseq, "file:", filename) def process_Glimmer3(filename, org_num, refseq): try: glimmer3_bed = get_bed_from_glimmer3(filename, refseq) except Exception as e: - print "Converting Glimmer3 to bed FAILED! For chrom:", refseq, "file:", filename, e + print("Converting Glimmer3 to bed FAILED! For chrom:", refseq, "file:", filename, e) glimmer3_bed = [] glimmer3_bed_file = open(os.path.join(os.path.split(filename)[0], "%s.Glimmer3.bed" % refseq), 'wb+') glimmer3_bed_file.write('\n'.join(glimmer3_bed)) @@ -187,7 +189,7 @@ def process_GeneMarkHMM(filename, org_num, refseq): try: geneMarkHMM_bed = get_bed_from_GeneMarkHMM(filename, refseq) except Exception as e: - print "Converting GeneMarkHMM to bed FAILED! For chrom:", refseq, "file:", filename, e + print("Converting GeneMarkHMM to bed FAILED! For chrom:", refseq, "file:", filename, e) geneMarkHMM_bed = [] geneMarkHMM_bed_bed_file = open(os.path.join(os.path.split(filename)[0], "%s.GeneMarkHMM.bed" % refseq), 'wb+') geneMarkHMM_bed_bed_file.write('\n'.join(geneMarkHMM_bed)) @@ -198,7 +200,7 @@ def process_GeneMark(filename, org_num, refseq): try: geneMark_bed = get_bed_from_GeneMark(filename, refseq) except Exception as e: - print "Converting GeneMark to bed FAILED! For chrom:", refseq, "file:", filename, e + print("Converting GeneMark to bed FAILED! For chrom:", refseq, "file:", filename, e) geneMark_bed = [] geneMark_bed_bed_file = open(os.path.join(os.path.split(filename)[0], "%s.GeneMark.bed" % refseq), 'wb+') geneMark_bed_bed_file.write('\n'.join(geneMark_bed)) @@ -211,13 +213,13 @@ def __main__(): try: base_dir = sys.argv[1] except: - print "using default base_dir:", base_dir + print("using default base_dir:", base_dir) try: os.mkdir(base_dir) - print "path '%s' has been created" % base_dir + print("path '%s' has been created" % base_dir) except: - print "path '%s' seems to already exist" % base_dir + print("path '%s' seems to already exist" % base_dir) for org_num, name, chroms, kingdom, group, org_genbank, org_refseq, info_url, ftp_url in iter_genome_projects(): if chroms is None: @@ -227,7 +229,7 @@ def __main__(): org_dir = os.path.join(base_dir, org_num) os.mkdir(org_dir) except: - print "Organism %s already exists on disk, skipping" % org_num + print("Organism %s already exists on disk, skipping" % org_num) continue # get ftp contents @@ -238,7 +240,7 @@ def __main__(): for refseq in chroms: scrape_ftp(ftp_contents, org_dir, org_num, refseq, ftp_url) # FTP Files have been Loaded - print "Org:", org_num, "chrom:", refseq, "[", time.time() - start_time, "seconds elapsed. ]" + print("Org:", org_num, "chrom:", refseq, "[", time.time() - start_time, "seconds elapsed. ]") # Create org info file info_file = open(os.path.join(org_dir, "%s.info" % org_num), 'wb+') @@ -251,9 +253,9 @@ def __main__(): info_file.write("ftp url=%s\n" % ftp_url) info_file.close() - print "Finished Harvesting", "[", time.time() - start_time, "seconds elapsed. ]" - print "[", (time.time() - start_time) / 60, "minutes. ]" - print "[", (time.time() - start_time) / 60 / 60, "hours. ]" + print("Finished Harvesting", "[", time.time() - start_time, "seconds elapsed. ]") + print("[", (time.time() - start_time) / 60, "minutes. ]") + print("[", (time.time() - start_time) / 60 / 60, "hours. ]") if __name__ == "__main__": diff --git a/scripts/microbes/ncbi_to_ucsc.py b/scripts/microbes/ncbi_to_ucsc.py index 7f65fe1c7c9..fb18d11b88a 100644 --- a/scripts/microbes/ncbi_to_ucsc.py +++ b/scripts/microbes/ncbi_to_ucsc.py @@ -3,6 +3,8 @@ Walk downloaded Genome Projects and Convert, in place, IDs to match the UCSC Archaea browser, where applicable. Uses UCSC Archaea DSN. """ +from __future__ import print_function + import os import sys import urllib @@ -15,7 +17,7 @@ def __main__(): try: base_dir = sys.argv[1] except: - print "using default base_dir:", base_dir + print("using default base_dir:", base_dir) organisms = {} for result in os.walk(base_dir): @@ -46,28 +48,26 @@ def __main__(): try: page = urllib.urlopen(URL) except: - print "#Unable to open " + URL - print "?\tunspecified (?)" + print("#Unable to open " + URL) + print("?\tunspecified (?)") sys.exit(1) text = page.read() try: tree = ElementTree.fromstring(text) except: - print "#Invalid xml passed back from " + URL - print "?\tunspecified (?)" + print("#Invalid xml passed back from " + URL) + print("?\tunspecified (?)") sys.exit(1) builds = {} - # print "#Harvested from http://archaea.ucsc.edu/cgi-bin/das/dsn" - # print "?\tunspecified (?)" for dsn in tree: build = dsn.find("SOURCE").attrib['id'] try: org_page = urllib.urlopen("http://archaea.ucsc.edu/cgi-bin/hgGateway?db=" + build).read().replace("\n", "").split("")[1].split("
")[0].split("") except: - print "NO CHROMS FOR", build + print("NO CHROMS FOR", build) continue org_page.pop(0) if org_page[-1] == "": @@ -82,12 +82,11 @@ def __main__(): if org not in builds: builds[org] = {'chrs': {}, 'build': build} builds[org]['chrs'][refseq] = chr - # print build,org,chr,refseq - print + print() ext_to_edit = ['bed', 'info', ] for org in builds: - print org, "changed to", builds[org]['build'] + print(org, "changed to", builds[org]['build']) # org info file info_file_old = os.path.join(base_dir + org, org + ".info") diff --git a/scripts/migrate_tools/migrate_tools.py b/scripts/migrate_tools/migrate_tools.py index a045c7a40a6..485d9031449 100644 --- a/scripts/migrate_tools/migrate_tools.py +++ b/scripts/migrate_tools/migrate_tools.py @@ -7,6 +7,8 @@ migrated_tools_conf.xml for tools outside tool panel sections as well as tools i layout of the local tool_conf.xml file. Entries will not be created in migrated_tools_conf.xml for tools included in the tool shed repository but not defined in tool_conf.xml. """ +from __future__ import print_function + import os import sys @@ -24,6 +26,6 @@ else: file_names = ', '.join(non_shed_tool_confs) msg = "\nThe installation process is finished. All tools associated with this migration that were defined in your file%s named\n" % plural msg += "%s, have been removed. You may now start your Galaxy server.\n" % file_names -print msg +print(msg) app.shutdown() sys.exit(0) diff --git a/scripts/others/incorrect_gops_jobs.py b/scripts/others/incorrect_gops_jobs.py index 30b081a2deb..610e077f979 100755 --- a/scripts/others/incorrect_gops_jobs.py +++ b/scripts/others/incorrect_gops_jobs.py @@ -3,6 +3,8 @@ Fetch jobs using gops_intersect, gops_merge, gops_subtract, gops_complement, gops_coverage wherein the second dataset doesn't have chr, start and end in standard columns 1, 2 and 3. """ +from __future__ import print_function + import ConfigParser import os import sys @@ -13,13 +15,13 @@ import sqlalchemy as sa import galaxy.app import galaxy.model.mapping -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) class TestApplication(object): """Encapsulates the state of a Universe application""" def __init__(self, database_connection=None, file_path=None): - print >> sys.stderr, "python path is: " + ", ".join(sys.path) + print("python path is: " + ", ".join(sys.path), file=sys.stderr) if database_connection is None: raise Exception("CleanupDatasetsApplication requires a database_connection value") if file_path is None: @@ -51,16 +53,16 @@ def main(): sa.and_(sa.or_(app.model.Job.table.c.tool_id == 'gops_complement_1', app.model.Job.table.c.tool_id == 'gops_merge_1'), sa.not_(app.model.Job.table.c.command_line.like('%-1 1,2,3%')))))).all(): - print "# processing job id %s" % str(job.id) + print("# processing job id %s" % str(job.id)) for jtoda in job.output_datasets: - print "# --> processing JobToOutputDatasetAssociation id %s" % str(jtoda.id) + print("# --> processing JobToOutputDatasetAssociation id %s" % str(jtoda.id)) hda = app.model.HistoryDatasetAssociation.get(jtoda.dataset_id) - print "# ----> processing HistoryDatasetAssociation id %s" % str(hda.id) + print("# ----> processing HistoryDatasetAssociation id %s" % str(hda.id)) if not hda.deleted: # Probably don't need this check, since the job state should suffice, but... if hda.dataset.state == 'ok': history = app.model.History.get(hda.history_id) - print "# ------> processing history id %s" % str(history.id) + print("# ------> processing history id %s" % str(history.id)) if history.user_id: cmd_line = str(job.command_line) new_output = tempfile.NamedTemporaryFile('w') @@ -77,7 +79,7 @@ def main(): diff_status = os.system('diff %s %s >> /dev/null' % (new_output.name, job_output)) if diff_status == 0: continue - print "# --------> Outputs differ" + print("# --------> Outputs differ") user = app.model.User.get(history.user_id) jobs[job.id] = {} jobs[job.id]['hda_id'] = hda.id @@ -88,20 +90,20 @@ def main(): jobs[job.id]['history_update_time'] = history.update_time jobs[job.id]['user_email'] = user.email except Exception as e: - print "# caught exception: %s" % str(e) + print("# caught exception: %s" % e) - print "\n\n# Number of incorrect Jobs: %d\n\n" % (len(jobs)) - print "#job_id\thda_id\thda_name\thda_info\thistory_id\thistory_name\thistory_update_time\tuser_email" + print("\n\n# Number of incorrect Jobs: %d\n\n" % (len(jobs))) + print("#job_id\thda_id\thda_name\thda_info\thistory_id\thistory_name\thistory_update_time\tuser_email") for jid in jobs: - print '%s\t%s\t"%s"\t"%s"\t%s\t"%s"\t"%s"\t%s' % \ + print('%s\t%s\t"%s"\t"%s"\t%s\t"%s"\t"%s"\t%s' % (str(jid), - str(jobs[jid]['hda_id']), - jobs[jid]['hda_name'], - jobs[jid]['hda_info'], - str(jobs[jid]['history_id']), - jobs[jid]['history_name'], - jobs[jid]['history_update_time'], - jobs[jid]['user_email']) + str(jobs[jid]['hda_id']), + jobs[jid]['hda_name'], + jobs[jid]['hda_info'], + str(jobs[jid]['history_id']), + jobs[jid]['history_name'], + jobs[jid]['history_update_time'], + jobs[jid]['user_email'])) sys.exit(0) diff --git a/scripts/others/incorrect_gops_join_jobs.py b/scripts/others/incorrect_gops_join_jobs.py index 328db003ccb..25e7ab0f4d1 100644 --- a/scripts/others/incorrect_gops_join_jobs.py +++ b/scripts/others/incorrect_gops_join_jobs.py @@ -2,6 +2,8 @@ """ Fetch gops_join wherein the use specified minimum coverage is not 1. """ +from __future__ import print_function + import ConfigParser import os import sys @@ -12,13 +14,13 @@ import sqlalchemy as sa import galaxy.app import galaxy.model.mapping -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) class TestApplication(object): """Encapsulates the state of a Universe application""" def __init__(self, database_connection=None, file_path=None): - print >> sys.stderr, "python path is: " + ", ".join(sys.path) + print("python path is: " + ", ".join(sys.path), file=sys.stderr) if database_connection is None: raise Exception("CleanupDatasetsApplication requires a database_connection value") if file_path is None: @@ -45,16 +47,16 @@ def main(): app.model.Job.table.c.state == 'ok', app.model.Job.table.c.tool_id == 'gops_join_1', sa.not_(app.model.Job.table.c.command_line.like('%-m 1 %')))).all(): - print "# processing job id %s" % str(job.id) + print("# processing job id %s" % str(job.id)) for jtoda in job.output_datasets: - print "# --> processing JobToOutputDatasetAssociation id %s" % str(jtoda.id) + print("# --> processing JobToOutputDatasetAssociation id %s" % str(jtoda.id)) hda = app.model.HistoryDatasetAssociation.get(jtoda.dataset_id) - print "# ----> processing HistoryDatasetAssociation id %s" % str(hda.id) + print("# ----> processing HistoryDatasetAssociation id %s" % str(hda.id)) if not hda.deleted: # Probably don't need this check, since the job state should suffice, but... if hda.dataset.state == 'ok': history = app.model.History.get(hda.history_id) - print "# ------> processing history id %s" % str(history.id) + print("# ------> processing history id %s" % str(history.id)) if history.user_id: cmd_line = str(job.command_line) new_output = tempfile.NamedTemporaryFile('w') @@ -67,7 +69,7 @@ def main(): diff_status = os.system('diff %s %s >> /dev/null' % (new_output.name, job_output)) if diff_status == 0: continue - print "# --------> Outputs differ" + print("# --------> Outputs differ") user = app.model.User.get(history.user_id) jobs[job.id] = {} jobs[job.id]['hda_id'] = hda.id @@ -78,20 +80,20 @@ def main(): jobs[job.id]['history_update_time'] = history.update_time jobs[job.id]['user_email'] = user.email except Exception as e: - print "# caught exception: %s" % str(e) + print("# caught exception: %s" % e) - print "\n\n# Number of incorrect Jobs: %d\n\n" % (len(jobs)) - print "#job_id\thda_id\thda_name\thda_info\thistory_id\thistory_name\thistory_update_time\tuser_email" + print("\n\n# Number of incorrect Jobs: %d\n\n" % (len(jobs))) + print("#job_id\thda_id\thda_name\thda_info\thistory_id\thistory_name\thistory_update_time\tuser_email") for jid in jobs: - print '%s\t%s\t"%s"\t"%s"\t%s\t"%s"\t"%s"\t%s' % \ + print('%s\t%s\t"%s"\t"%s"\t%s\t"%s"\t"%s"\t%s' % (str(jid), - str(jobs[jid]['hda_id']), - jobs[jid]['hda_name'], - jobs[jid]['hda_info'], - str(jobs[jid]['history_id']), - jobs[jid]['history_name'], - jobs[jid]['history_update_time'], - jobs[jid]['user_email']) + str(jobs[jid]['hda_id']), + jobs[jid]['hda_name'], + jobs[jid]['hda_info'], + str(jobs[jid]['history_id']), + jobs[jid]['history_name'], + jobs[jid]['history_update_time'], + jobs[jid]['user_email'])) sys.exit(0) diff --git a/scripts/set_dataset_sizes.py b/scripts/set_dataset_sizes.py index 1bd446c04c1..7c5b36e0c86 100644 --- a/scripts/set_dataset_sizes.py +++ b/scripts/set_dataset_sizes.py @@ -1,4 +1,6 @@ #!/usr/bin/env python +from __future__ import print_function + import os import sys from ConfigParser import ConfigParser @@ -36,15 +38,15 @@ def init(): if __name__ == '__main__': - print 'Loading Galaxy model...' + print('Loading Galaxy model...') model, object_store = init() sa_session = model.context.current set = 0 dataset_count = sa_session.query(model.Dataset).count() - print 'Processing %i datasets...' % dataset_count + print('Processing %i datasets...' % dataset_count) percent = 0 - print 'Completed %i%%' % percent, + print('Completed %i%%' % percent, end=' ') sys.stdout.flush() for i, dataset in enumerate(sa_session.query(model.Dataset).enable_eagerloads(False).yield_per(1000)): if dataset.total_size is None: @@ -55,8 +57,8 @@ if __name__ == '__main__': new_percent = int(float(i) / dataset_count * 100) if new_percent != percent: percent = new_percent - print '\rCompleted %i%%' % percent, + print('\rCompleted %i%%' % percent, end=' ') sys.stdout.flush() sa_session.flush() - print 'Completed 100%%' + print('\rCompleted 100%') object_store.shutdown() diff --git a/scripts/set_user_disk_usage.py b/scripts/set_user_disk_usage.py index 40ef34d6838..ff48168ab89 100755 --- a/scripts/set_user_disk_usage.py +++ b/scripts/set_user_disk_usage.py @@ -1,4 +1,6 @@ #!/usr/bin/env python +from __future__ import print_function + import os import sys from ConfigParser import ConfigParser @@ -50,25 +52,25 @@ def init(): def quotacheck(sa_session, users, engine): sa_session.refresh(user) current = user.get_disk_usage() - print user.username, '<' + user.email + '>:', + print(user.username, '<' + user.email + '>:', end=' ') if engine not in ('postgres', 'postgresql'): new = user.calculate_disk_usage() sa_session.refresh(user) # usage changed while calculating, do it again if user.get_disk_usage() != current: - print 'usage changed while calculating, trying again...' + print('usage changed while calculating, trying again...') return quotacheck(sa_session, user, engine) else: new = pgcalc(sa_session, user.id, dryrun=options.dryrun) # yes, still a small race condition between here and the flush - print 'old usage:', nice_size(current), 'change:', + print('old usage:', nice_size(current), 'change:', end=' ') if new in (current, None): - print 'none' + print('none') else: if new > current: - print '+%s' % (nice_size(new - current)) + print('+%s' % (nice_size(new - current))) else: - print '-%s' % (nice_size(current - new)) + print('-%s' % (nice_size(current - new))) if not options.dryrun and engine not in ('postgres', 'postgresql'): user.set_disk_usage(new) sa_session.add(user) @@ -76,17 +78,17 @@ def quotacheck(sa_session, users, engine): if __name__ == '__main__': - print 'Loading Galaxy model...' + print('Loading Galaxy model...') model, object_store, engine = init() sa_session = model.context.current if not options.username and not options.email: user_count = sa_session.query(model.User).count() - print 'Processing %i users...' % user_count + print('Processing %i users...' % user_count) for i, user in enumerate(sa_session.query(model.User).enable_eagerloads(False).yield_per(1000)): - print '%3i%%' % int(float(i) / user_count * 100), + print('%3i%%' % int(float(i) / user_count * 100), end=' ') quotacheck(sa_session, user, engine) - print '100% complete' + print('100% complete') object_store.shutdown() sys.exit(0) elif options.username: @@ -94,7 +96,7 @@ if __name__ == '__main__': elif options.email: user = sa_session.query(model.User).enable_eagerloads(False).filter_by(email=options.email).first() if not user: - print 'User not found' + print('User not found') sys.exit(1) object_store.shutdown() quotacheck(sa_session, user, engine) diff --git a/scripts/slideshow/build_slideshow.py b/scripts/slideshow/build_slideshow.py index fac0da49568..03d77d4a392 100644 --- a/scripts/slideshow/build_slideshow.py +++ b/scripts/slideshow/build_slideshow.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import os import string import sys @@ -20,7 +22,7 @@ def main(argv=None): 'title': title, 'content': content, }) - print html + print(html) open(output, "w").write(html) diff --git a/scripts/tool_shed/api/add_repository_registry_entry.py b/scripts/tool_shed/api/add_repository_registry_entry.py index b57cc3554de..c493675be11 100644 --- a/scripts/tool_shed/api/add_repository_registry_entry.py +++ b/scripts/tool_shed/api/add_repository_registry_entry.py @@ -5,6 +5,7 @@ Add appropriate entries to the Tool Shed's repository registry for a specified r Here is a working example of how to use this script. python ./add_repository_registry_entry.py -a -u -n -o """ +from __future__ import print_function import argparse @@ -22,11 +23,11 @@ def main(options): data['owner'] = options.owner url = '%s%s' % (base_tool_shed_url, '/api/repositories/add_repository_registry_entry') response_dict = submit(url, data, api_key=api_key, return_formatted=False) - print response_dict + print(response_dict) else: - print "Invalid tool_shed: ", base_tool_shed_url, " name: ", options.name, " or owner: ", options.owner, "." + print("Invalid tool_shed: ", base_tool_shed_url, " name: ", options.name, " or owner: ", options.owner, ".") else: - print "An API key for an admin user in the Tool Shed is required to add entries into the Tool Shed's repository registry." + print("An API key for an admin user in the Tool Shed is required to add entries into the Tool Shed's repository registry.") if __name__ == '__main__': diff --git a/scripts/tool_shed/api/common.py b/scripts/tool_shed/api/common.py index 97462c7d3cc..d3871f36aa5 100644 --- a/scripts/tool_shed/api/common.py +++ b/scripts/tool_shed/api/common.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import json import os import sys @@ -62,15 +64,15 @@ def delete(api_key, url, data, return_formatted=True): response = json.loads(delete_request.read()) except urllib2.HTTPError as e: if return_formatted: - print e - print e.read(1024) + print(e) + print(e.read(1024)) sys.exit(1) else: return dict(status='error', message=str(e.read(1024))) if return_formatted: - print 'Response' - print '--------' - print response + print('Response') + print('--------') + print(response) else: return response @@ -80,40 +82,40 @@ def display(url, api_key=None, return_formatted=True): try: r = get(url, api_key=api_key) except urllib2.HTTPError as e: - print e + print(e) # Only return the first 1K of errors. - print e.read(1024) + print(e.read(1024)) sys.exit(1) if type(r) == unicode: - print 'error: %s' % r + print('error: %s' % r) return None if not return_formatted: return r elif type(r) == list: # Response is a collection as defined in the REST style. - print 'Collection Members' - print '------------------' + print('Collection Members') + print('------------------') for n, i in enumerate(r): # All collection members should have a name in the response. # url is optional if 'url' in i: - print '#%d: %s' % (n + 1, i.pop('url')) + print('#%d: %s' % (n + 1, i.pop('url'))) if 'name' in i: - print ' name: %s' % i.pop('name') + print(' name: %s' % i.pop('name')) for k, v in i.items(): - print ' %s: %s' % (k, v) - print '' - print '%d element(s) in collection' % len(r) + print(' %s: %s' % (k, v)) + print() + print('%d element(s) in collection' % len(r)) elif type(r) == dict: # Response is an element as defined in the REST style. - print 'Member Information' - print '------------------' + print('Member Information') + print('------------------') for k, v in r.items(): - print '%s: %s' % (k, v) + print('%s: %s' % (k, v)) elif type(r) == str: - print r + print(r) else: - print 'response is unknown type: %s' % type(r) + print('response is unknown type: %s' % type(r)) def get(url, api_key=None): @@ -195,7 +197,7 @@ def json_from_url(url): parsed_json = json.loads(url_contents) except Exception as e: error_message = str(url_contents) - print 'Error parsing JSON data in json_from_url(): ', str(e) + print('Error parsing JSON data in json_from_url():', e) return None, error_message return parsed_json, error_message @@ -242,32 +244,32 @@ def submit(url, data, api_key=None, return_formatted=True): response = post(url, data, api_key=api_key) except urllib2.HTTPError as e: if return_formatted: - print e - print e.read(1024) + print(e) + print(e.read(1024)) sys.exit(1) else: return dict(status='error', message=str(e.read(1024))) if not return_formatted: return response - print 'Response' - print '--------' + print('Response') + print('--------') if type(response) == list: # Currently the only implemented responses are lists of dicts, because submission creates # some number of collection elements. for i in response: if type(i) == dict: if 'url' in i: - print i.pop('url') + print(i.pop('url')) else: - print '----' + print('----') if 'name' in i: - print ' name: %s' % i.pop('name') + print(' name: %s' % i.pop('name')) for k, v in i.items(): - print ' %s: %s' % (k, v) + print(' %s: %s' % (k, v)) else: - print i + print(i) else: - print response + print(response) def update(api_key, url, data, return_formatted=True): @@ -279,14 +281,14 @@ def update(api_key, url, data, return_formatted=True): response = put(url, data, api_key=api_key) except urllib2.HTTPError as e: if return_formatted: - print e - print e.read(1024) + print(e) + print(e.read(1024)) sys.exit(1) else: return dict(status='error', message=str(e.read(1024))) if return_formatted: - print 'Response' - print '--------' - print response + print('Response') + print('--------') + print(response) else: return response diff --git a/scripts/tool_shed/api/create_categories.py b/scripts/tool_shed/api/create_categories.py index b26be8c068b..38a3309f925 100644 --- a/scripts/tool_shed/api/create_categories.py +++ b/scripts/tool_shed/api/create_categories.py @@ -17,6 +17,7 @@ available in the test public Tool Shed and create each of them in a local develo ./create_categories.py -a -f http://testtoolshed.g2.bx.psu.edu -t http://localhost:9009 """ +from __future__ import print_function import argparse @@ -42,7 +43,7 @@ def main(options): response = submit(url, data, api_key) except Exception as e: response = str(e) - print "Error attempting to create category using URL: ", url, " exception: ", str(e) + print("Error attempting to create category using URL: ", url, " exception: ", e) create_response_dict = dict(response=response) create_response_dicts.append(create_response_dict) diff --git a/scripts/tool_shed/api/create_users.py b/scripts/tool_shed/api/create_users.py index 83dc19c1ab4..954ef1ff057 100644 --- a/scripts/tool_shed/api/create_users.py +++ b/scripts/tool_shed/api/create_users.py @@ -18,6 +18,7 @@ are available in the test public Tool Shed and create each of them in a local de ./create_users.py -a -f http://testtoolshed.g2.bx.psu.edu -t http://localhost:9009 """ +from __future__ import print_function import argparse @@ -45,7 +46,7 @@ def main(options): response = submit(url, data, api_key) except Exception as e: response = str(e) - print "Error attempting to create user using URL: ", url, " exception: ", str(e) + print("Error attempting to create user using URL: ", url, " exception: ", e) create_response_dict = dict(response=response) create_response_dicts.append(create_response_dict) diff --git a/scripts/tool_shed/api/export.py b/scripts/tool_shed/api/export.py index 05b43f53f78..7ee251e4206 100644 --- a/scripts/tool_shed/api/export.py +++ b/scripts/tool_shed/api/export.py @@ -6,6 +6,7 @@ dependencies from the tool shed into a compressed archive. Here is a working example of how to use this script to export a repository from the tool shed. ./export.py --url http://testtoolshed.g2.bx.psu.edu --name chemicaltoolbox --owner bgruening --revision 4133dbf7ff4d --export_repository_dependencies True --download_dir /tmp """ +from __future__ import print_function import argparse import os @@ -85,7 +86,7 @@ def main(options): export_dict = submit(url, data, return_formatted=False) error_messages = export_dict['error_messages'] if error_messages: - print "Error attempting to export revision ", options.changeset_revision, " of repository ", options.name, " owned by ", options.owner, ":\n", error_messages + print("Error attempting to export revision ", options.changeset_revision, " of repository ", options.name, " owned by ", options.owner, ":\n", error_messages) else: export_repository_dependencies = string_as_bool(options.export_repository_dependencies) repositories_archive_filename = \ @@ -104,10 +105,10 @@ def main(options): for chunk in src.iter_content(chunk_size=CHUNK_SIZE): if chunk: dst.write(chunk) - print "Successfully exported revision ", options.changeset_revision, " of repository ", options.name, " owned by ", options.owner - print "to location ", file_path + print("Successfully exported revision ", options.changeset_revision, " of repository ", options.name, " owned by ", options.owner) + print("to location ", file_path) else: - print "Invalid tool_shed / name / owner ." + print("Invalid tool_shed / name / owner .") if __name__ == '__main__': diff --git a/scripts/tool_shed/api/get_filtered_repository_revisions.py b/scripts/tool_shed/api/get_filtered_repository_revisions.py index b5805e697bc..91a527d4713 100644 --- a/scripts/tool_shed/api/get_filtered_repository_revisions.py +++ b/scripts/tool_shed/api/get_filtered_repository_revisions.py @@ -19,6 +19,7 @@ This script is useful for analyzing the Tool Shed's install and test framework. Here is a working example of how to use this script. ./get_filtered_repository_revisions.py --url http://testtoolshed.g2.bx.psu.edu """ +from __future__ import print_function import argparse import os @@ -54,7 +55,7 @@ def main(options): api_url = get_api_url(base=base_tool_shed_url, parts=parts, params=params) baseline_repository_dicts, error_message = json_from_url(api_url) if baseline_repository_dicts is None or error_message: - print error_message + print(error_message) else: repository_dicts = [] for baseline_repository_dict in baseline_repository_dicts: @@ -62,7 +63,7 @@ def main(options): # module that will generate the install methods. repository_dict, error_message = get_repository_dict(base_tool_shed_url, baseline_repository_dict) if error_message: - print 'Error getting additional details from the API: ', error_message + print('Error getting additional details from the API: ', error_message) repository_dicts.append(baseline_repository_dict) else: # Don't test empty repositories. @@ -76,8 +77,8 @@ def main(options): repository_dicts.append(dict(repository_dict.items() + baseline_repository_dict.items())) else: repository_dicts.append(dict(repository_dict.items() + baseline_repository_dict.items())) - print '\n\n', repository_dicts - print '\nThe url:\n\n', api_url, '\n\nreturned ', len(repository_dicts), ' repository dictionaries...' + print('\n\n', repository_dicts) + print('\nThe url:\n\n', api_url, '\n\nreturned ', len(repository_dicts), ' repository dictionaries...') if __name__ == '__main__': diff --git a/scripts/tool_shed/api/remove_repository_registry_entry.py b/scripts/tool_shed/api/remove_repository_registry_entry.py index 66248bd27c5..96a25e48f53 100644 --- a/scripts/tool_shed/api/remove_repository_registry_entry.py +++ b/scripts/tool_shed/api/remove_repository_registry_entry.py @@ -5,6 +5,7 @@ Remove appropriate entries from the Tool Shed's repository registry for a specif Here is a working example of how to use this script. python ./remove_repository_registry_entry.py -a -u -n -o """ +from __future__ import print_function import argparse @@ -22,11 +23,11 @@ def main(options): data['owner'] = options.owner url = '%s%s' % (base_tool_shed_url, '/api/repositories/remove_repository_registry_entry') response_dict = submit(url, data, api_key=api_key, return_formatted=False) - print response_dict + print(response_dict) else: - print "Invalid tool_shed: ", base_tool_shed_url, " name: ", options.name, " or owner: ", options.owner, "." + print("Invalid tool_shed: ", base_tool_shed_url, " name: ", options.name, " or owner: ", options.owner, ".") else: - print "An API key for an admin user in the Tool Shed is required to remove entries from the Tool Shed's repository registry." + print("An API key for an admin user in the Tool Shed is required to remove entries from the Tool Shed's repository registry.") if __name__ == '__main__': diff --git a/scripts/tool_shed/api/reset_metadata_on_repositories.py b/scripts/tool_shed/api/reset_metadata_on_repositories.py index 6c14253af42..b2791686c51 100644 --- a/scripts/tool_shed/api/reset_metadata_on_repositories.py +++ b/scripts/tool_shed/api/reset_metadata_on_repositories.py @@ -11,6 +11,8 @@ usage: reset_metadata_on_repositories.py key Here is a working example of how to use this script to reset metadata on certain repositories in a specified Tool Shed. python ./reset_metadata_on_repositories.py -a 22be3b -m True -u http://localhost:9009/ """ +from __future__ import print_function + import argparse import logging import os @@ -56,9 +58,9 @@ def main(options): repository_ids = get(url, api_key) for repository_id in repository_ids: if repository_id in encoded_ids_to_skip: - print "--------" - print "Skipping repository with id %s because it is in skip file %s" % (str(repository_id), str(skip_file)) - print "--------" + print("--------") + print("Skipping repository with id %s because it is in skip file %s" % (repository_id, skip_file)) + print("--------") else: data = dict(repository_id=repository_id) url = '%s/api/repositories/reset_metadata_on_repository' % base_tool_shed_url diff --git a/scripts/tool_shed/bootstrap_tool_shed/bootstrap_util.py b/scripts/tool_shed/bootstrap_tool_shed/bootstrap_util.py index 6d91d9bf87a..dacf5acb3d3 100755 --- a/scripts/tool_shed/bootstrap_tool_shed/bootstrap_util.py +++ b/scripts/tool_shed/bootstrap_tool_shed/bootstrap_util.py @@ -1,4 +1,6 @@ #!/usr/bin/python +from __future__ import print_function + import ConfigParser import optparse import os @@ -75,7 +77,7 @@ def admin_user_info(): email = None password = None if tree is None: - print "The XML file ", user_info_config, " seems to be invalid, using defaults." + print("The XML file ", user_info_config, " seems to be invalid, using defaults.") email = 'admin@test.org' password = 'testuser' username = 'admin' @@ -97,7 +99,7 @@ def get_local_tool_shed_url(config_parser): if config_parser.has_option('server:main', 'port'): port = config_parser.get('server:main', 'port') host = '127.0.0.1' - print 'http://%s:%s' % (host, port) + print('http://%s:%s' % (host, port)) return 0 @@ -113,7 +115,7 @@ def main(args): return check_db(config_parser) elif args.method == 'admin_user_info': (username, email, password) = admin_user_info() - print '%s__SEP__%s__SEP__%s' % (username, email, password) + print('%s__SEP__%s__SEP__%s' % (username, email, password)) return 0 elif args.method == 'get_url': return get_local_tool_shed_url(config_parser) diff --git a/scripts/tool_shed/bootstrap_tool_shed/create_user_with_api_key.py b/scripts/tool_shed/bootstrap_tool_shed/create_user_with_api_key.py index 001c001a87d..683690f3c2b 100644 --- a/scripts/tool_shed/bootstrap_tool_shed/create_user_with_api_key.py +++ b/scripts/tool_shed/bootstrap_tool_shed/create_user_with_api_key.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +from __future__ import print_function import ConfigParser import logging @@ -33,7 +34,7 @@ class BootstrapApplication(object): self.config = config if not self.config.database_connection: self.config.database_connection = "sqlite:///%s?isolation_level=IMMEDIATE" % str(config.database) - print 'Using database connection: ', self.config.database_connection + print('Using database connection: ', self.config.database_connection) # Setup the database engine and ORM self.model = mapping.init(self.config.file_path, self.config.database_connection, @@ -42,7 +43,7 @@ class BootstrapApplication(object): self.security = security.SecurityHelper(id_secret=self.config.id_secret) self.hgweb_config_manager = self.model.hgweb_config_manager self.hgweb_config_manager.hgweb_config_dir = self.config.hgweb_config_dir - print 'Using hgweb.config file: ', self.hgweb_config_manager.hgweb_config + print('Using hgweb.config file: ', self.hgweb_config_manager.hgweb_config) @property def sa_session(self): @@ -68,7 +69,7 @@ def create_user(app): if email and password and username: invalid_message = validate(email, password, username) if invalid_message: - print invalid_message + print(invalid_message) else: user = app.model.User(email=email) user.set_password_cleartext(password) @@ -78,7 +79,7 @@ def create_user(app): app.model.security_agent.create_private_user_role(user) return user else: - print "Missing required values for email: ", email, ", password: ", password, ", username: ", username + print("Missing required values for email: ", email, ", password: ", password, ", username: ", username) return None @@ -124,7 +125,7 @@ if __name__ == "__main__": (args, options) = parser.parse_args() ini_file = args.config config_parser = ConfigParser.ConfigParser({'here': os.getcwd()}) - print "Reading ini file: ", ini_file + print("Reading ini file: ", ini_file) config_parser.read(ini_file) config_dict = {} for key, value in config_parser.items("app:main"): @@ -134,7 +135,7 @@ if __name__ == "__main__": user = create_user(app) if user is not None: api_key = create_api_key(app, user) - print "Created new user with public username '", user.username, ". An API key was also created and associated with the user." + print("Created new user with public username '", user.username, ". An API key was also created and associated with the user.") sys.exit(0) else: sys.exit("Problem creating a new user and an associated API key.") diff --git a/scripts/tool_shed/build_ts_whoosh_index.py b/scripts/tool_shed/build_ts_whoosh_index.py index 95644610482..031cfa5f3d5 100644 --- a/scripts/tool_shed/build_ts_whoosh_index.py +++ b/scripts/tool_shed/build_ts_whoosh_index.py @@ -10,6 +10,8 @@ Make sure you adjusted your config to: This script expects the Tool Shed's runtime virtualenv to be active. """ +from __future__ import print_function + import ConfigParser import logging import os @@ -97,7 +99,6 @@ def build_index(sa_session, whoosh_index_dir, path_to_repositories): full_last_updated=repo.get('full_last_updated')) # Tools get their own index for tool in repo.get('tools_list'): - # print tool tool_index_writer.add_document(id=to_unicode(tool.get('id')), name=to_unicode(tool.get('name')), version=to_unicode(tool.get('version')), @@ -107,16 +108,16 @@ def build_index(sa_session, whoosh_index_dir, path_to_repositories): repo_name=to_unicode(repo.get('name')), repo_id=repo.get('id')) tools_indexed += 1 - print tools_indexed, 'tools (', tool.get('id'), ')' + print(tools_indexed, 'tools (', tool.get('id'), ')') repos_indexed += 1 - print repos_indexed, 'repos (', repo.get('id'), ')' + print(repos_indexed, 'repos (', repo.get('id'), ')') tool_index_writer.commit() repo_index_writer.commit() - print "TOTAL repos indexed: ", repos_indexed - print "TOTAL tools indexed: ", tools_indexed + print("TOTAL repos indexed: ", repos_indexed) + print("TOTAL tools indexed: ", tools_indexed) def get_repos(sa_session, path_to_repositories): diff --git a/scripts/tool_shed/check_download_urls.py b/scripts/tool_shed/check_download_urls.py index 192797bb52f..85cf73d0ac4 100644 --- a/scripts/tool_shed/check_download_urls.py +++ b/scripts/tool_shed/check_download_urls.py @@ -2,6 +2,8 @@ # Dan Blankenberg # Script that checks toolshed tags to see if URLs are accessible. # Does not currently handle 'download_binary' +from __future__ import print_function + import os import urllib2 import xml.etree.ElementTree as ET @@ -30,9 +32,9 @@ def main(): try: urllib2.urlopen(urllib2.Request(url)) except Exception as e: - print "Bad URL '%s' in file '%s': %s" % (url, path, e) + print("Bad URL '%s' in file '%s': %s" % (url, path, e)) except Exception as e: - print "Unable to check XML file '%s': %s" % (path, e) + print("Unable to check XML file '%s': %s" % (path, e)) if __name__ == "__main__": diff --git a/scripts/tool_shed/check_filesystem_for_empty_tool_dependency_installation_paths.py b/scripts/tool_shed/check_filesystem_for_empty_tool_dependency_installation_paths.py index 49271dc0b63..eaab4633fda 100644 --- a/scripts/tool_shed/check_filesystem_for_empty_tool_dependency_installation_paths.py +++ b/scripts/tool_shed/check_filesystem_for_empty_tool_dependency_installation_paths.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import argparse import os import shutil @@ -11,9 +13,9 @@ from tool_shed.util.basic_util import INSTALLATION_LOG def main(args): empty_installation_paths = [] if not os.path.exists(args.basepath): - print 'Tool dependency path %s does not exist.' % str(args.basepath) + print('Tool dependency path "%s" does not exist.' % args.basepath) return 1 - print 'Checking path %s for empty tool dependency installation directories.' % args.basepath + print('Checking path "%s" for empty tool dependency installation directories.' % args.basepath) for root, dirs, files in os.walk(args.basepath): path_parts = root.replace(args.basepath, '').lstrip('/').split(os.sep) # Skip certain special directories. @@ -35,18 +37,18 @@ def main(args): if no_files and no_dirs and root not in empty_installation_paths: empty_installation_paths.append(root) if len(empty_installation_paths) > 0: - print 'The following %d tool dependency installation directories were found to be empty or contain only the file %s.' % \ - (len(empty_installation_paths), INSTALLATION_LOG) + print('The following %d tool dependency installation directories were found to be empty or contain only the file %s.' % + (len(empty_installation_paths), INSTALLATION_LOG)) if args.delete: for path in empty_installation_paths: if os.path.exists(path): shutil.rmtree(path) - print 'Deleted %s.' % path + print('Deleted %s.' % path) else: for empty_installation_path in empty_installation_paths: - print empty_installation_path + print(empty_installation_path) else: - print 'No empty tool dependency installation directories found.' + print('No empty tool dependency installation directories found.') return 0 diff --git a/scripts/tool_shed/check_s3_for_empty_tool_dependency_installation_paths.py b/scripts/tool_shed/check_s3_for_empty_tool_dependency_installation_paths.py index 3366c2cea55..4005b29a0fd 100644 --- a/scripts/tool_shed/check_s3_for_empty_tool_dependency_installation_paths.py +++ b/scripts/tool_shed/check_s3_for_empty_tool_dependency_installation_paths.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import argparse import os import sys @@ -23,15 +25,15 @@ class BucketList(object): def display_empty_installation_paths(self): for empty_installation_path in self.empty_installation_paths: - print empty_installation_path + print(empty_installation_path) def delete_empty_installation_paths(self): - print 'Deleting empty installation paths.' + print('Deleting empty installation paths.') for empty_installation_path in self.empty_installation_paths: # Get all keys in the S3 bucket that start with the installation path, and delete each one. for path_to_delete in self.bucket.list(prefix=empty_installation_path): self.bucket.delete_key(path_to_delete.key) - print 'Deleted empty path %s' % str(empty_installation_path) + print('Deleted empty path %s' % empty_installation_path) def get_tool_dependency_install_paths(self): found_paths = [] @@ -92,22 +94,22 @@ def main(args): if args.s3passwd is not None and os.path.exists(args.s3passwd): awsid, secret = open(args.s3passwd, 'r').read().rstrip('\n').split(':') else: - print 'Amazon ID and secret not provided, and no s3passwd file found.' + print('Amazon ID and secret not provided, and no s3passwd file found.') return 1 else: awsid = args.id secret = args.secret dependency_cleaner = BucketList(awsid, secret, args.bucket) if len(dependency_cleaner.empty_installation_paths) == 0: - print 'No empty installation paths found, exiting.' + print('No empty installation paths found, exiting.') return 0 - print 'The following %d tool dependency installation paths were found to be empty or contain only the file %s.' % \ - (len(dependency_cleaner.empty_installation_paths), INSTALLATION_LOG) + print('The following %d tool dependency installation paths were found to be empty or contain only the file %s.' % + (len(dependency_cleaner.empty_installation_paths), INSTALLATION_LOG)) if asbool(args.delete): dependency_cleaner.delete_empty_installation_paths() else: for empty_installation_path in dependency_cleaner.empty_installation_paths: - print empty_installation_path + print(empty_installation_path) return 0 diff --git a/scripts/tool_shed/clean_up_tool_dependency_directory.py b/scripts/tool_shed/clean_up_tool_dependency_directory.py index 3c5d7fccfa8..a8899c5f383 100644 --- a/scripts/tool_shed/clean_up_tool_dependency_directory.py +++ b/scripts/tool_shed/clean_up_tool_dependency_directory.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import argparse import os import shutil @@ -6,12 +8,12 @@ import sys def main(args): if not os.path.exists(args.tool_dependency_dir): - print 'Tool dependency base path %s does not exist, creating.' % str(args.tool_dependency_dir) + print('Tool dependency base path "%s" does not exist, creating.' % args.tool_dependency_dir) os.mkdir(args.tool_dependency_dir) return 0 else: for content in os.listdir(args.tool_dependency_dir): - print 'Deleting directory %s from %s.' % (content, args.tool_dependency_dir) + print('Deleting directory "%s" from "%s" .' % (content, args.tool_dependency_dir)) full_path = os.path.join(args.tool_dependency_dir, content) if os.path.isdir(full_path): shutil.rmtree(full_path) diff --git a/scripts/tool_shed/deprecate_repositories_without_metadata.py b/scripts/tool_shed/deprecate_repositories_without_metadata.py index 1a31604e6e1..e573c051f90 100644 --- a/scripts/tool_shed/deprecate_repositories_without_metadata.py +++ b/scripts/tool_shed/deprecate_repositories_without_metadata.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +from __future__ import print_function import ConfigParser import logging @@ -26,7 +27,7 @@ from galaxy.util import ( log = logging.getLogger() log.setLevel(10) log.addHandler(logging.StreamHandler(sys.stdout)) -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) def build_citable_url(host, repository): @@ -56,11 +57,11 @@ def main(): app = DeprecateRepositoriesApplication(config) cutoff_time = datetime.utcnow() - timedelta(days=options.days) now = strftime("%Y-%m-%d %H:%M:%S") - print "\n####################################################################################" - print "# %s - Handling stuff older than %i days" % (now, options.days) + print("\n####################################################################################") + print("# %s - Handling stuff older than %i days" % (now, options.days)) if options.info_only: - print "# Displaying info only ( --info_only )" + print("# Displaying info only ( --info_only )") deprecate_repositories(app, cutoff_time, days=options.days, info_only=options.info_only, verbose=options.verbose) @@ -75,10 +76,10 @@ def send_mail_to_owner(app, name, owner, email, repositories_deprecated, days=14 # an environment variable named TOOL_SHED_CANONICAL_URL be set, pointing to the tool shed that is being checked. url = os.environ.get('TOOL_SHED_CANONICAL_URL', None) if None in [smtp_server, from_address]: - print '# Mail not configured, not sending email to repository owner.' + print('# Mail not configured, not sending email to repository owner.') return elif url is None: - print '# Environment variable TOOL_SHED_CANONICAL_URL not set, not sending email to repository owner.' + print('# Environment variable TOOL_SHED_CANONICAL_URL not set, not sending email to repository owner.') return subject = "Regarding your tool shed repositories at %s" % url message_body_template = 'The tool shed automated repository checker has discovered that one or more of your repositories hosted ' + \ @@ -91,10 +92,10 @@ def send_mail_to_owner(app, name, owner, email, repositories_deprecated, days=14 body += '\n'.join([build_citable_url(url, repository) for repository in repositories_deprecated]) try: galaxy_send_mail(from_address, repository.user.email, subject, body, app.config) - print "# An email has been sent to %s, the owner of %s." % (repository.user.username, ', '.join([repository.name for repository in repositories_deprecated])) + print("# An email has been sent to %s, the owner of %s." % (repository.user.username, ', '.join([repository.name for repository in repositories_deprecated]))) return True except Exception as e: - print "# An error occurred attempting to send email: %s" % str(e) + print("# An error occurred attempting to send email: %s" % e) return False @@ -129,10 +130,10 @@ def deprecate_repositories(app, cutoff_time, days=14, info_only=False, verbose=F .filter(app.model.Repository.table.c.id == repository_id).one() owner = repository.user if info_only: - print '# Repository %s owned by %s would have been deprecated, but info_only was set.' % (repository.name, repository.user.username) + print('# Repository %s owned by %s would have been deprecated, but info_only was set.' % (repository.name, repository.user.username)) else: if verbose: - print '# Deprecating repository %s owned by %s.' % (repository.name, owner.username) + print('# Deprecating repository %s owned by %s.' % (repository.name, owner.username)) if owner.username not in repositories_by_owner: repositories_by_owner[owner.username] = dict(owner=owner, repositories=[]) repositories_by_owner[owner.username]['repositories'].append(repository) @@ -146,9 +147,9 @@ def deprecate_repositories(app, cutoff_time, days=14, info_only=False, verbose=F owner = repositories_by_owner[repository_owner]['owner'] send_mail_to_owner(app, repository.name, owner.username, owner.email, repositories_by_owner[repository_owner]['repositories'], days) stop = time.time() - print '# Deprecated %d repositories.' % len(repositories) - print "# Elapsed time: ", stop - start - print "####################################################################################" + print('# Deprecated %d repositories.' % len(repositories)) + print("# Elapsed time: ", stop - start) + print("####################################################################################") class DeprecateRepositoriesApplication(object): diff --git a/scripts/tool_shed/migrate_tools_to_repositories.py b/scripts/tool_shed/migrate_tools_to_repositories.py index c90a5299129..a5d5770922a 100644 --- a/scripts/tool_shed/migrate_tools_to_repositories.py +++ b/scripts/tool_shed/migrate_tools_to_repositories.py @@ -18,6 +18,8 @@ enable_next_gen_tool_shed = True To run this script, use "sh migrate_tools_to_repositories.sh" from this directory ''' +from __future__ import print_function + import ConfigParser import os import shutil @@ -32,7 +34,7 @@ sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pa import galaxy.webapps.tool_shed.app -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) def directory_hash_id(id): @@ -83,7 +85,7 @@ def create_repository_from_tool(app, sa_session, tool): # Make the repository name a form of the tool's tool_id by # lower-casing everything and replacing any blank spaces with underscores. repo_name = tool.tool_id.lower().replace(' ', '_') - print "Creating repository '%s' in database" % (repo_name) + print("Creating repository '%s' in database" % (repo_name)) repository = app.model.Repository(name=repo_name, description=tool.description, user_id=tool.user_id) @@ -101,19 +103,19 @@ def create_repository_from_tool(app, sa_session, tool): if not os.path.exists(repository_path): os.makedirs(repository_path) # Create the local hg repository - print "Creating repository '%s' on disk" % (os.path.abspath(repository_path)) + print("Creating repository '%s' on disk" % (os.path.abspath(repository_path))) hg.repository(ui.ui(), os.path.abspath(repository_path), create=True) # Add an entry in the hgweb.config file for the new repository - this enables calls to repository.repo_path add_hgweb_config_entry(repository, repository_path) # Migrate tool categories for tca in tool.categories: category = tca.category - print "Associating category '%s' with repository '%s' in database" % (category.name, repository.name) + print("Associating category '%s' with repository '%s' in database" % (category.name, repository.name)) rca = app.model.RepositoryCategoryAssociation(repository, category) sa_session.add(rca) sa_session.flush() # Migrate tool ratings - print "Associating ratings for tool '%s' with repository '%s'" % (tool.name, repository.name) + print("Associating ratings for tool '%s' with repository '%s'" % (tool.name, repository.name)) for tra in tool.ratings: rra = app.model.RepositoryRatingAssociation(user=tra.user, rating=tra.rating, @@ -167,8 +169,8 @@ def add_tool_files_to_repository(app, sa_session, tool): # Get all valid versions of the tool tool_versions = get_versions(app, tool) for tool_version in tool_versions: - print "------------------------------" - print "Migrating tool '%s' version '%s' from archive to repository '%s'" % (tool_version.tool_id, tool_version.version, repo_path) + print("------------------------------") + print("Migrating tool '%s' version '%s' from archive to repository '%s'" % (tool_version.tool_id, tool_version.version, repo_path)) # Make a temporary working directory tmp_dir = tempfile.mkdtemp() tmp_archive_dir = os.path.join(tmp_dir, 'tmp_archive_dir') @@ -208,13 +210,13 @@ def add_tool_files_to_repository(app, sa_session, tool): for dir in dirs: os.system("hg add %s" % dir) for name in files: - print "Adding file '%s' to cloned repository at %s" % (name, str(os.getcwd())) + print("Adding file '%s' to cloned repository at %s" % (name, os.getcwd())) os.system("hg add %s" % name) - print "Committing change set to cloned repository at %s" % str(os.getcwd()) + print("Committing change set to cloned repository at %s" % os.getcwd()) os.system("hg commit -m 'Migrated tool version %s from old tool shed archive to new tool shed repository'" % tool_version.version) - print "Pushing changeset from cloned repository '%s' to repository '%s'" % (cloned_repo_dir, repo_path) + print("Pushing changeset from cloned repository '%s' to repository '%s'" % (cloned_repo_dir, repo_path)) cmd = "hg push %s" % repo_path - print "cmd is: ", cmd + print("cmd is: ", cmd) os.system(cmd) # The tool shed includes a repository source file browser, which currently depends upon # copies of the hg repository file store in the repo_path for browsing. We'll do the @@ -266,12 +268,12 @@ def tool_archive_file_name(tool, file_name): def main(): if len(sys.argv) < 2: - print "Usage: python %s " % sys.argv[0] + print("Usage: python %s " % sys.argv[0]) sys.exit(0) now = strftime("%Y-%m-%d %H:%M:%S") - print " " - print "##########################################" - print "%s - Migrating current tool archives to new tool repositories" % now + print() + print("##########################################") + print("%s - Migrating current tool archives to new tool repositories" % now) # tool_shed_wsgi.ini file ini_file = sys.argv[1] conf_parser = ConfigParser.ConfigParser({'here': os.getcwd()}) @@ -280,7 +282,7 @@ def main(): db_conn_str = conf_parser.get("app:main", "database_connection") except ConfigParser.NoOptionError: db_conn_str = conf_parser.get("app:main", "database_file") - print 'DB Connection: ', db_conn_str + print('DB Connection: ', db_conn_str) # Instantiate app configuration = {} for key, value in conf_parser.items("app:main"): @@ -290,7 +292,7 @@ def main(): # Remove the hgweb.config file if it exists hgweb_config = "%s/hgweb.config" % os.getcwd() if os.path.exists(hgweb_config): - print "Removing old file: ", hgweb_config + print("Removing old file: ", hgweb_config) os.remove(hgweb_config) repo_records = 0 rca_records = 0 @@ -300,11 +302,11 @@ def main(): # tool files exist in app.config.file_path/tools and we don't want to delete them dir = os.path.join(app.config.file_path, *directory_hash_id(repo.id)) if os.path.exists(dir): - print "Removing old repository file directory: ", dir + print("Removing old repository file directory: ", dir) shutil.rmtree(dir) # Delete all records from db tables: # repository_category_association, repository_rating_association, repository - print "Deleting db records for repository: ", repo.name + print("Deleting db records for repository: ", repo.name) for rca in repo.categories: sa_session.delete(rca) rca_records += 1 @@ -314,9 +316,9 @@ def main(): sa_session.delete(repo) repo_records += 1 sa_session.flush() - print "Deleted %d rows from the repository table" % repo_records - print "Deleted %d rows from the repository_category_association table" % rca_records - print "Deleted %d rows from the repository_rating_association table" % rra_records + print("Deleted %d rows from the repository table" % repo_records) + print("Deleted %d rows from the repository_category_association table" % rca_records) + print("Deleted %d rows from the repository_rating_association table" % rra_records) # Migrate database tool, tool category and tool rating records to new # database repository, repository category and repository rating records # and create the hg repository on disk for each. @@ -327,9 +329,9 @@ def main(): for tool in get_approved_tools(app, sa_session): add_tool_files_to_repository(app, sa_session, tool) app.shutdown() - print ' ' - print 'Migration to next gen tool shed complete...' - print "##########################################" + print() + print('Migration to next gen tool shed complete...') + print("##########################################") sys.exit(0) diff --git a/scripts/tool_shed/show_tool_dependency_installation_dir_contents.py b/scripts/tool_shed/show_tool_dependency_installation_dir_contents.py index 7978c4b205e..b030a820c85 100644 --- a/scripts/tool_shed/show_tool_dependency_installation_dir_contents.py +++ b/scripts/tool_shed/show_tool_dependency_installation_dir_contents.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import argparse import os import sys @@ -28,17 +30,17 @@ class CleanUpDependencyApplication(object): def main(args, app): if not os.path.exists(args.basepath): - print 'Tool dependency base path %s does not exist.' % str(args.basepath) + print('Tool dependency base path "%s" does not exist.' % args.basepath) return - print 'Checking tool dependency path %s' % args.basepath + print('Checking tool dependency path %s' % args.basepath) tool_dependency_dirs = get_tool_dependency_dirs(app) for tool_dependency_dir in tool_dependency_dirs: path = os.path.join(args.basepath, tool_dependency_dir) if os.path.exists(path): path_contents = os.listdir(path) if len(path_contents) > 0: - print 'Found non-empty tool dependency installation directory %s.' % path - print 'Directory has the following contents: \n %s' % '\n '.join(path_contents) + print('Found non-empty tool dependency installation directory %s.' % path) + print('Directory has the following contents: \n %s' % '\n '.join(path_contents)) def get_tool_dependency_dirs(app): diff --git a/scripts/tools/maf/check_loc_file.py b/scripts/tools/maf/check_loc_file.py index 96be0d8f7ce..f7e3d32e984 100644 --- a/scripts/tools/maf/check_loc_file.py +++ b/scripts/tools/maf/check_loc_file.py @@ -1,13 +1,15 @@ # Dan Blankenberg # This script checks maf_index.loc file for inconsistencies between what is listed as available and what is really available. # Make sure that required dependencies (e.g. galaxy_root/lib) are included in your PYTHONPATH +from __future__ import print_function + import sys import bx.align.maf from galaxy.tools.util import maf_utilities -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) def __main__(): @@ -39,19 +41,19 @@ def __main__(): # indexed species for spec in indexed_for_species: if spec not in species_indexed_in_maf: - print "Line %i, %s claims to be indexed for %s, but indexes do not exist." % (i, uid, spec) + print("Line %i, %s claims to be indexed for %s, but indexes do not exist." % (i, uid, spec)) for spec in species_indexed_in_maf: if spec not in indexed_for_species: - print "Line %i, %s is indexed for %s, but is not listed in loc file." % (i, uid, spec) + print("Line %i, %s is indexed for %s, but is not listed in loc file." % (i, uid, spec)) # existing species for spec in species_exist: if spec not in species_found_in_maf: - print "Line %i, %s claims to have blocks for %s, but was not found in MAF files." % (i, uid, spec) + print("Line %i, %s claims to have blocks for %s, but was not found in MAF files." % (i, uid, spec)) for spec in species_found_in_maf: if spec not in species_exist: - print "Line %i, %s contains %s, but is not listed in loc file." % (i, uid, spec) + print("Line %i, %s contains %s, but is not listed in loc file." % (i, uid, spec)) except Exception as e: - print "Line %i is invalid: %s" % (i, e) + print("Line %i is invalid: %s" % (i, e)) if __name__ == "__main__": diff --git a/scripts/update_shed_config_path.py b/scripts/update_shed_config_path.py index d3962c96f66..673847bf6d2 100644 --- a/scripts/update_shed_config_path.py +++ b/scripts/update_shed_config_path.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import argparse import ConfigParser import os @@ -34,7 +36,7 @@ def create_database(config_file): if database_connection is None: database_connection = 'sqlite:///%s' % parser.get('app:main', 'database_file') if database_connection is None: - print 'Unable to determine correct database connection.' + print('Unable to determine correct database connection.') exit(1) '''Initialize the database file.''' @@ -54,7 +56,7 @@ if __name__ == '__main__': parser.add_argument('--force', dest='force', action='store_true', help="Use this flag to set the new path even if the file does not (yet) exist there.") opts = parser.parse_args() if not os.path.exists(opts.good_filename) and not opts.force: - print 'The file %s does not exist, use the --force option to proceed.' % opts.good_filename + print('The file %s does not exist, use the --force option to proceed.' % opts.good_filename) exit(1) session, model = create_database(opts.config_file) exit(main(opts, session, model)) diff --git a/test/unit/managers/test_CollectionManager.py b/test/unit/managers/test_CollectionManager.py index c6ce34af1b6..651fdc12000 100644 --- a/test/unit/managers/test_CollectionManager.py +++ b/test/unit/managers/test_CollectionManager.py @@ -49,10 +49,6 @@ class DatasetCollectionManagerTestCase(BaseTestCase, CreatesCollectionsMixin): self.assertFalse(hdca.deleted) self.assertTrue(hdca.visible) - # print 'hdca dir:' - # for k in dir( hdca ): - # print k, getattr( hdca, k, '(?)' ) - self.log("should contain an underlying, well-formed DatasetCollection") self.assertIsInstance(hdca.collection, model.DatasetCollection) collection = hdca.collection @@ -61,15 +57,6 @@ class DatasetCollectionManagerTestCase(BaseTestCase, CreatesCollectionsMixin): self.assertEqual(len(collection.dataset_instances), 3) self.assertEqual(len(collection.elements), 3) - # print 'hdca.collection dir:' - # for k in dir( hdca.collection ): - # print k, getattr( hdca.collection, k, '(?)' ) - - # elements = collection.elements - # print 'hdca.collection element dir:' - # for k in dir( elements[0] ): - # print k, getattr( elements[0], k, '(?)' ) - self.log("and that collection should have three well-formed Elements") self.assertIsInstance(collection.elements[0], model.DatasetCollectionElement) self.assertEqual(collection.elements[0].element_identifier, 'one') diff --git a/test/unit/managers/test_HistoryContentsManager.py b/test/unit/managers/test_HistoryContentsManager.py index 7a5a6443041..f45040a3177 100644 --- a/test/unit/managers/test_HistoryContentsManager.py +++ b/test/unit/managers/test_HistoryContentsManager.py @@ -96,17 +96,8 @@ class HistoryAsContainerTestCase(HistoryAsContainerBaseTestCase): contents.extend([self.add_hda_to_history(history, name=('hda-' + str(x))) for x in range(4, 6)]) contents.append(self.add_list_collection_to_history(history, contents[4:6])) - # _subquery = self.contents_manager._contents_common_query( self.contents_manager.subcontainer_class, history.id ) - # _subquery = self.contents_manager._contents_common_query( self.contents_manager.contained_class, history.id ) - # print _subquery - # for row in _subquery.all(): - # print row - self.log("should be able to limit and offset") results = self.contents_manager.contents(history) - # print [ r.id for r in results ] - # print '--' - # print [ c.id for c in contents ] self.assertEqual(results, contents) self.assertEqual(self.contents_manager.contents(history, limit=4), contents[0:4]) @@ -134,8 +125,6 @@ class HistoryAsContainerTestCase(HistoryAsContainerBaseTestCase): # TODO: cross db compat? filters = [text('deleted = 1')] - # for content in self.contents_manager.contents( history, filters=filters ): - # print content.hid, content.history_content_type, content.id, content.name self.assertEqual(self.contents_manager.contents(history, filters=filters), deleted) # even stranger that sqlalx can use the first model in the union (HDA) for columns across the union @@ -151,8 +140,6 @@ class HistoryAsContainerTestCase(HistoryAsContainerBaseTestCase): contents[5].visible = False contents[6].visible = False invisible = [contents[2], contents[5], contents[6]] - # for content in invisible: - # print content.id, content.__class__.__name__, content self.app.model.context.flush() filters = [text('visible = 0')] diff --git a/test/unit/managers/test_HistoryManager.py b/test/unit/managers/test_HistoryManager.py index 530295b9c82..f14ee9512a8 100644 --- a/test/unit/managers/test_HistoryManager.py +++ b/test/unit/managers/test_HistoryManager.py @@ -713,8 +713,6 @@ class HistoryFiltersTestCase(BaseTestCase): ('name', 'like', 'history%'), ]) histories = self.history_manager.list(filters=filters) - # for h in histories: - # print h.name self.assertEqual(histories, [history1, history2, history3]) filters = self.filter_parser.parse_filters([('name', 'like', '%2'), ]) diff --git a/test/unit/unittest_utils/galaxy_mock.py b/test/unit/unittest_utils/galaxy_mock.py index e73bd56c3e9..6cc2d1905bb 100644 --- a/test/unit/unittest_utils/galaxy_mock.py +++ b/test/unit/unittest_utils/galaxy_mock.py @@ -199,7 +199,6 @@ class MockDir(object): def create_root(self, structure_dict, where=None): self.root_path = tempfile.mkdtemp(dir=where) - # print 'created root:', self.root_path self.create_structure(self.root_path, structure_dict) def create_structure(self, current_path, structure_dict): @@ -210,17 +209,14 @@ class MockDir(object): # if it's a dict, create a dir here named k and recurse into it if isinstance(v, dict): subdir_path = os.path.join(current_path, k) - # print 'subdir:', subdir_path os.mkdir(subdir_path) self.create_structure(subdir_path, v) def create_file(self, path, contents): - # print 'file:', path with open(path, 'w') as newfile: newfile.write(contents) def remove(self): - # print 'removing:', self.root_path shutil.rmtree(self.root_path) diff --git a/test/unit/visualizations/plugins/test_VisualizationsRegistry.py b/test/unit/visualizations/plugins/test_VisualizationsRegistry.py index 7ed3b8af10a..ef912bd433c 100644 --- a/test/unit/visualizations/plugins/test_VisualizationsRegistry.py +++ b/test/unit/visualizations/plugins/test_VisualizationsRegistry.py @@ -258,7 +258,6 @@ class VisualizationsRegistry_TestCase(unittest.TestCase): trans = galaxy_mock.MockTrans() script_entry._set_up_template_plugin(mock_app_dir.root_path, [addtional_templates_dir]) response = script_entry._render({}, trans=trans, embedded=True) - # print response self.assertTrue('src="bler"' in response) self.assertTrue('type="text/javascript"' in response) self.assertTrue('data-main="one"' in response) diff --git a/tools/data_source/fetch.py b/tools/data_source/fetch.py index 7c5bc41f781..687b8cfcf96 100644 --- a/tools/data_source/fetch.py +++ b/tools/data_source/fetch.py @@ -8,7 +8,7 @@ import sys from six.moves.urllib.request import urlopen -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) BUFFER = 1048576 diff --git a/tools/data_source/genbank.py b/tools/data_source/genbank.py index 864ebc9bd09..cd21103be7a 100644 --- a/tools/data_source/genbank.py +++ b/tools/data_source/genbank.py @@ -6,7 +6,7 @@ import textwrap from Bio import GenBank -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) def make_fasta(rec): diff --git a/tools/data_source/import.py b/tools/data_source/import.py index 162a7a5b9ae..4a4c2bf0616 100644 --- a/tools/data_source/import.py +++ b/tools/data_source/import.py @@ -8,7 +8,7 @@ from __future__ import print_function import os import sys -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) BUFFER = 1048576 diff --git a/tools/data_source/microbial_import.py b/tools/data_source/microbial_import.py index e53cdc3d06e..196a60a7ae8 100644 --- a/tools/data_source/microbial_import.py +++ b/tools/data_source/microbial_import.py @@ -8,7 +8,7 @@ from __future__ import print_function import sys from shutil import copyfile -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) BUFFER = 1048576 diff --git a/tools/filters/bed_to_gff_converter.py b/tools/filters/bed_to_gff_converter.py index ce647167766..6507257d022 100644 --- a/tools/filters/bed_to_gff_converter.py +++ b/tools/filters/bed_to_gff_converter.py @@ -4,7 +4,7 @@ from __future__ import print_function import sys -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) def __main__(): diff --git a/tools/filters/gtf_to_bedgraph_converter.py b/tools/filters/gtf_to_bedgraph_converter.py index 1638a4edd21..4dc7a1802fa 100644 --- a/tools/filters/gtf_to_bedgraph_converter.py +++ b/tools/filters/gtf_to_bedgraph_converter.py @@ -5,7 +5,7 @@ import os import sys import tempfile -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) def __main__(): diff --git a/tools/filters/ucsc_gene_bed_to_exon_bed.py b/tools/filters/ucsc_gene_bed_to_exon_bed.py index 081d2917f06..10fe200f231 100755 --- a/tools/filters/ucsc_gene_bed_to_exon_bed.py +++ b/tools/filters/ucsc_gene_bed_to_exon_bed.py @@ -18,7 +18,7 @@ from __future__ import print_function import optparse import sys -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) def main(): @@ -49,12 +49,6 @@ def main(): sys.exit(0) print("Region:", options.region + ";") - """print "Only overlap with Exons:", - if options.exons: - print "Yes" - else: - print "No" - """ # Read table and handle each gene for line in in_file: diff --git a/tools/filters/ucsc_gene_bed_to_exon_bed.xml b/tools/filters/ucsc_gene_bed_to_exon_bed.xml index e606cc8da11..bceb50a63b9 100644 --- a/tools/filters/ucsc_gene_bed_to_exon_bed.xml +++ b/tools/filters/ucsc_gene_bed_to_exon_bed.xml @@ -1,6 +1,6 @@ expander - ucsc_gene_bed_to_exon_bed.py --input=$input1 --output=$out_file1 --region=$region "--exons" + ucsc_gene_bed_to_exon_bed.py --input=$input1 --output=$out_file1 --region=$region --exons diff --git a/tools/filters/ucsc_gene_bed_to_intron_bed.py b/tools/filters/ucsc_gene_bed_to_intron_bed.py index b43029a9ee8..b6818a8757d 100755 --- a/tools/filters/ucsc_gene_bed_to_intron_bed.py +++ b/tools/filters/ucsc_gene_bed_to_intron_bed.py @@ -18,7 +18,7 @@ from __future__ import print_function import optparse import sys -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) def main(): diff --git a/tools/filters/ucsc_gene_table_to_intervals.py b/tools/filters/ucsc_gene_table_to_intervals.py index 80e82188bd0..4c10404f24c 100755 --- a/tools/filters/ucsc_gene_table_to_intervals.py +++ b/tools/filters/ucsc_gene_table_to_intervals.py @@ -18,7 +18,7 @@ from __future__ import print_function import optparse import sys -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) def main(): diff --git a/tools/metag_tools/shrimp_wrapper.py b/tools/metag_tools/shrimp_wrapper.py index e20f6e180ee..632033a08e0 100644 --- a/tools/metag_tools/shrimp_wrapper.py +++ b/tools/metag_tools/shrimp_wrapper.py @@ -50,7 +50,7 @@ import re import sys import tempfile -assert sys.version_info[:2] >= (2.4) +assert sys.version_info[:2] >= (2, 6) def stop_err(msg): diff --git a/tools/sr_assembly/velvetg_wrapper.py b/tools/sr_assembly/velvetg_wrapper.py index 4db9b71ed28..170fbd9341a 100644 --- a/tools/sr_assembly/velvetg_wrapper.py +++ b/tools/sr_assembly/velvetg_wrapper.py @@ -9,7 +9,7 @@ import os import subprocess import sys -assert sys.version_info[:2] >= (2, 4) +assert sys.version_info[:2] >= (2, 6) def stop_err(msg):