From 027c65a8da1b47cf795e9cd609398e77fb1e9a89 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Wed, 8 Apr 2015 22:40:51 -0400 Subject: [PATCH 01/10] Remove unused method form install_environment. settings is undefined so this is a previous clear sign the method is unused. --- .../tool_dependencies/recipe/install_environment.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/tool_shed/galaxy_install/tool_dependencies/recipe/install_environment.py b/lib/tool_shed/galaxy_install/tool_dependencies/recipe/install_environment.py index 1c9c132b802..d336c711f42 100644 --- a/lib/tool_shed/galaxy_install/tool_dependencies/recipe/install_environment.py +++ b/lib/tool_shed/galaxy_install/tool_dependencies/recipe/install_environment.py @@ -46,11 +46,6 @@ class InstallEnvironment( object ): self.install_dir = install_dir self.tool_shed_repository_install_dir = tool_shed_repository_install_dir - def __call__( self ): - with settings( warn_only=True, **basic_util.get_env_var_values( self ) ): - with prefix( self.__setup_environment() ): - yield - def add_env_shell_file_paths( self, paths ): for path in paths: self.env_shell_file_paths.append( str( path ) ) From b24875679a6001b79f3e2aeb6dbc5fcd4a4b5f2c Mon Sep 17 00:00:00 2001 From: John Chilton Date: Wed, 8 Apr 2015 22:48:13 -0400 Subject: [PATCH 02/10] Remove broken method from library_common. That method could never have done anything but throw an exception or return [], this commit just assumes that it was always returning [] and updates the one place it was called accordingly. Not sure what widgets are - but I don't think @martenson is implementing them in the data library rewrite. This method was originally added in f7334104a000f36fd1c5f8f18cf617b399b7ff0f --- .../webapps/galaxy/controllers/library_common.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/lib/galaxy/webapps/galaxy/controllers/library_common.py b/lib/galaxy/webapps/galaxy/controllers/library_common.py index 1a7bfd80f6a..4f530d61dec 100644 --- a/lib/galaxy/webapps/galaxy/controllers/library_common.py +++ b/lib/galaxy/webapps/galaxy/controllers/library_common.py @@ -1432,7 +1432,6 @@ class LibraryCommon( BaseUIController, UsesFormDefinitionsMixin, UsesExtendedMet message = 'Select at least one dataset from the list of active datasets in your current history' status = 'error' upload_option = kwd.get( 'upload_option', 'import_from_history' ) - widgets = self._get_populated_widgets( folder ) # Send list of data formats to the upload form so the "extension" select list can be populated dynamically file_formats = trans.app.datatypes_registry.upload_file_formats # Send list of genome builds to the form so the "dbkey" select list can be populated dynamically @@ -1459,7 +1458,7 @@ class LibraryCommon( BaseUIController, UsesFormDefinitionsMixin, UsesExtendedMet last_used_build=last_used_build, roles_select_list=roles_select_list, history=history, - widgets=widgets, + widgets=[], template_id=template_id, space_to_tab=space_to_tab, link_data_only=link_data_only, @@ -1515,16 +1514,6 @@ class LibraryCommon( BaseUIController, UsesFormDefinitionsMixin, UsesExtendedMet upload_option_select_list.add_option( option_label, option_value, selected=option_value==upload_option ) return upload_option_select_list - def _get_populated_widgets( self, folder ): - # See if we have any inherited templates. - info_association, inherited = folder.get_info_association( inherited=True ) - if info_association and info_association.inheritable: - widgets = folder.get_template_widgets( trans, get_contents=True ) - # Retain contents of widget fields when form was submitted via refresh_on_change. - return self.populate_widgets_from_kwd( trans, widgets, **kwd ) - else: - return [] - @web.expose def download_dataset_from_folder( self, trans, cntrller, id, library_id=None, **kwd ): """Catches the dataset id and displays file contents as directed""" From 124243b24e4eae5a305bab39e65800bd182b522b Mon Sep 17 00:00:00 2001 From: John Chilton Date: Wed, 8 Apr 2015 22:52:08 -0400 Subject: [PATCH 03/10] Fix unknown name library_dataset in _check_manage of library_common. Again - was completely broken - couldn't have worked as previously implemented This variant seems to make more sense. --- lib/galaxy/webapps/galaxy/controllers/library_common.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/galaxy/webapps/galaxy/controllers/library_common.py b/lib/galaxy/webapps/galaxy/controllers/library_common.py index 4f530d61dec..2206c586baa 100644 --- a/lib/galaxy/webapps/galaxy/controllers/library_common.py +++ b/lib/galaxy/webapps/galaxy/controllers/library_common.py @@ -2573,8 +2573,8 @@ class LibraryCommon( BaseUIController, UsesFormDefinitionsMixin, UsesExtendedMet # Deny access if the user is not an admin and does not have the LIBRARY_MANAGE and DATASET_MANAGE_PERMISSIONS permissions. if not ( is_admin or \ ( trans.app.security_agent.can_manage_library_item( current_user_roles, item ) and - trans.app.security_agent.can_manage_dataset( current_user_roles, library_dataset.library_dataset_dataset_association.dataset ) ) ): - message = "You are not authorized to manage permissions on library dataset (%s)." % escape( library_dataset.name ) + trans.app.security_agent.can_manage_dataset( current_user_roles, item.library_dataset_dataset_association.dataset ) ) ): + message = "You are not authorized to manage permissions on library dataset (%s)." % escape( item.name ) if cntrller == 'api': return 403, message return trans.response.send_redirect( web.url_for( controller='library_common', From db5bea46a6661bd9d8bc6a2c3bef0aeafc0c07f7 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Wed, 8 Apr 2015 22:55:29 -0400 Subject: [PATCH 04/10] Remove broken and seemingly unused method from external_services. Can find no callers for this method in templates, test, or lib. The method is broken anyway (trans not defined). --- lib/galaxy/external_services/service.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/lib/galaxy/external_services/service.py b/lib/galaxy/external_services/service.py index 2bc11848162..fe6fa1ce628 100644 --- a/lib/galaxy/external_services/service.py +++ b/lib/galaxy/external_services/service.py @@ -210,19 +210,5 @@ class PopulatedExternalService( object ): assert action, 'Action not found: %s' % actions_list return action - def get_action_links( self ): - rval = [] - param_dict = {} - param_dict['fields'] = Bunch( **self.service_instance.form_values.content ) - param_dict['item'] = self.item - for item in self.service.items: - if isinstance( item, ExternalServiceParameter ): - param_dict[ item.name ] = item.get_value( param_dict ) - elif isinstance( item, ExternalServiceAction ): - rval.append( item.get_action_access_link( self.item, trans, param_dict ) ) - elif isinstance( item, ExternalServiceActionsGroup ): - rval.extend( item.populate( self.service_instance, item, param_dict ).get_action_links() ) - else: - raise 'unknown item type found' def __nonzero__( self ): return self.actions.has_action() From bf5176664de9e3630edcd9b2580d47ec40ed756f Mon Sep 17 00:00:00 2001 From: John Chilton Date: Wed, 8 Apr 2015 23:02:26 -0400 Subject: [PATCH 05/10] Fix missing import in galaxy.webapps.tool_shed.api.repositories. --- lib/galaxy/webapps/tool_shed/api/repositories.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/galaxy/webapps/tool_shed/api/repositories.py b/lib/galaxy/webapps/tool_shed/api/repositories.py index 92fb87f519f..c92070157ef 100644 --- a/lib/galaxy/webapps/tool_shed/api/repositories.py +++ b/lib/galaxy/webapps/tool_shed/api/repositories.py @@ -12,6 +12,7 @@ from galaxy import util from galaxy import web from galaxy.exceptions import RequestParameterMissingException from galaxy.exceptions import RequestParameterInvalidException +from galaxy.exceptions import InsufficientPermissionsException from galaxy.exceptions import ActionInputError from galaxy.exceptions import ObjectNotFound from galaxy.exceptions import MalformedId From 453dde829eb04128202d9837dae83e893a1676ab Mon Sep 17 00:00:00 2001 From: John Chilton Date: Wed, 8 Apr 2015 23:04:06 -0400 Subject: [PATCH 06/10] Fix unknown name self in tool_shed.scripts.api.export. --- lib/tool_shed/scripts/api/export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tool_shed/scripts/api/export.py b/lib/tool_shed/scripts/api/export.py index dea6c5dd211..bfb6c17c74a 100644 --- a/lib/tool_shed/scripts/api/export.py +++ b/lib/tool_shed/scripts/api/export.py @@ -25,7 +25,7 @@ def generate_repository_archive_filename( tool_shed_url, name, owner, changeset_ export_repository_dependencies, use_tmp_archive_dir=False ): tool_shed = remove_protocol_from_tool_shed_url( tool_shed_url ) file_type_str = basic_util.get_file_type_str( changeset_revision, file_type ) - if self.export_repository_dependencies: + if export_repository_dependencies: repositories_archive_filename = '%s_%s_%s_%s_%s' % ( CAPSULE_WITH_DEPENDENCIES_FILENAME, tool_shed, name, From dc256aebf22497cfce57de04e33fd606f97e485e Mon Sep 17 00:00:00 2001 From: John Chilton Date: Wed, 8 Apr 2015 23:06:12 -0400 Subject: [PATCH 07/10] Fix tool shed scripts that log without creating a log. --- lib/tool_shed/scripts/api/import_capsule.py | 3 ++- lib/tool_shed/scripts/api/reset_metadata_on_repositories.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/tool_shed/scripts/api/import_capsule.py b/lib/tool_shed/scripts/api/import_capsule.py index 3f9bce80351..e58cc25df82 100644 --- a/lib/tool_shed/scripts/api/import_capsule.py +++ b/lib/tool_shed/scripts/api/import_capsule.py @@ -14,7 +14,8 @@ method (they'll have to be created manually, which can be done after the import) Here is a working example of how to use this script to install a repository from the test tool shed. ./import_capsule.py -a -u http://localhost:9009 -c capsule_localhost_colon_9009_filter_test1_8923f52d5c6d.tar.gz """ - +import logging +log = logging.getLogger(__name__) import os import sys import argparse diff --git a/lib/tool_shed/scripts/api/reset_metadata_on_repositories.py b/lib/tool_shed/scripts/api/reset_metadata_on_repositories.py index 104689e87ac..fe3a1fcf64e 100644 --- a/lib/tool_shed/scripts/api/reset_metadata_on_repositories.py +++ b/lib/tool_shed/scripts/api/reset_metadata_on_repositories.py @@ -11,7 +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/ """ - +import logging +log = logging.getLogger(__name__) import argparse import os import sys From 6d49f1ef51017c9534f98729782c4c34764e5f8a Mon Sep 17 00:00:00 2001 From: John Chilton Date: Wed, 8 Apr 2015 23:08:10 -0400 Subject: [PATCH 08/10] Fix undefined variables in remote_repository_registry_entry. --- lib/tool_shed/scripts/api/remove_repository_registry_entry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tool_shed/scripts/api/remove_repository_registry_entry.py b/lib/tool_shed/scripts/api/remove_repository_registry_entry.py index 5eec6ecfe11..730b3262693 100644 --- a/lib/tool_shed/scripts/api/remove_repository_registry_entry.py +++ b/lib/tool_shed/scripts/api/remove_repository_registry_entry.py @@ -26,7 +26,7 @@ def main( options ): response_dict = submit( url, data, api_key=api_key, return_formatted=False ) print response_dict else: - print "Invalid tool_shed: ", base_tool_shed_url, " name: ", name, " or owner: ", 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." From 7c9413c13d87699c6d451e930488ffd574e8e6c7 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Wed, 8 Apr 2015 23:08:30 -0400 Subject: [PATCH 09/10] Fix undefined name in recently refactored yaml_to_workflow.py. --- test/api/yaml_to_workflow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/api/yaml_to_workflow.py b/test/api/yaml_to_workflow.py index 6771fa252b9..890180ccff5 100644 --- a/test/api/yaml_to_workflow.py +++ b/test/api/yaml_to_workflow.py @@ -17,7 +17,7 @@ STEP_TYPE_ALIASES = { def yaml_to_workflow(has_yaml): as_python = yaml.load(has_yaml) - return python_to_workflow(as_path) + return python_to_workflow(as_python) def python_to_workflow(as_python): From 577107ec05dcddd43ecf5ab7e3809174b20454dc Mon Sep 17 00:00:00 2001 From: John Chilton Date: Wed, 8 Apr 2015 23:14:57 -0400 Subject: [PATCH 10/10] TraivsCI: More aggressive checks for very broken stuff. Seems we are far from a consensus on style-based linting - but it should be not controversial that referenced variables should be defined and file syntax should be valid. --- .ci/flake8_wrapper.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.ci/flake8_wrapper.sh b/.ci/flake8_wrapper.sh index e606be9d1d0..63108bc4903 100755 --- a/.ci/flake8_wrapper.sh +++ b/.ci/flake8_wrapper.sh @@ -2,6 +2,11 @@ set -e +# Run broad range of checks over specific white-listed files, this uses +# the default checks defined in setup.cfg. while read p; do flake8 $(eval echo "$p") done <.ci/pep8_sources.txt + +# Look for obviously broken stuff lots more places. +flake8 --select=E901,E902,F821,F822,F823,F831 --exclude lib/galaxy/util/pastescript/serve.py lib/{galaxy,tool_shed} test/{api,unit}