From e7600bdf0c4b2feeb467a3c19ca685cf359f42b5 Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Fri, 5 Jul 2019 18:15:20 +0200 Subject: [PATCH] Fix Python 2.7 lint errors --- lib/galaxy/auth/__init__.py | 3 +-- lib/galaxy/auth/util.py | 5 +++-- lib/galaxy/config/__init__.py | 18 +++++++++--------- lib/galaxy/config/script.py | 2 +- lib/galaxy/model/orm/scripts.py | 2 +- lib/galaxy/tools/special_tools.py | 3 ++- lib/galaxy/web/framework/webapp.py | 2 +- lib/tool_shed/galaxy_install/migrate/check.py | 2 +- .../galaxy_install/tool_migration_manager.py | 3 +-- lib/tool_shed/util/common_util.py | 4 ++-- setup.py | 2 +- 11 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/galaxy/auth/__init__.py b/lib/galaxy/auth/__init__.py index 843f4d761e6..470f7667fef 100644 --- a/lib/galaxy/auth/__init__.py +++ b/lib/galaxy/auth/__init__.py @@ -1,7 +1,6 @@ """ Contains implementations of the authentication logic. """ -import errno import logging from galaxy.auth.util import get_authenticators, parse_auth_results @@ -16,7 +15,7 @@ class AuthManager(object): def __init__(self, app): self.__app = app self.redact_username_in_logs = app.config.redact_username_in_logs - self.authenticators = get_authenticators(app.config.auth_config_file) + self.authenticators = get_authenticators(app.config.auth_config_file, app.config.auth_config_file_set) def check_registration_allowed(self, email, username, password): """Checks if the provided email/username is allowed to register.""" diff --git a/lib/galaxy/auth/util.py b/lib/galaxy/auth/util.py index 28b39400190..86bec13c692 100644 --- a/lib/galaxy/auth/util.py +++ b/lib/galaxy/auth/util.py @@ -1,3 +1,4 @@ +import errno import logging import xml.etree.ElementTree from collections import namedtuple @@ -24,14 +25,14 @@ AUTH_CONF_XML = """ Authenticator = namedtuple('Authenticator', ['plugin', 'filter_template', 'options']) -def get_authenticators(auth_config_file): +def get_authenticators(auth_config_file, auth_config_file_set): __plugins_dict = plugin_config.plugins_dict(galaxy.auth.providers, 'plugin_type') # parse XML try: ct = xml.etree.ElementTree.parse(auth_config_file) conf_root = ct.getroot() except (OSError, IOError) as exc: - if exc.errno == errno.ENOENT and not app.config.auth_config_file_set: + if exc.errno == errno.ENOENT and not auth_config_file_set: conf_root = xml.etree.ElementTree.fromstring(AUTH_CONF_XML) else: raise diff --git a/lib/galaxy/config/__init__.py b/lib/galaxy/config/__init__.py index 293ba1e4306..7e996d8f2a7 100644 --- a/lib/galaxy/config/__init__.py +++ b/lib/galaxy/config/__init__.py @@ -217,18 +217,18 @@ class BaseAppConfiguration(object): def _parse_config_file_options(self, defaults, listify_defaults, config_kwargs): for var, defaults in defaults.items(): - if config_kwargs.get( var, None ) is not None: - path = config_kwargs.get( var ) - setattr( self, var + '_set', True ) + if config_kwargs.get(var, None) is not None: + path = config_kwargs.get(var) + setattr(self, var + '_set', True) else: for default in defaults: - if os.path.exists( resolve_path( default, self.root ) ): + if os.path.exists(resolve_path(default, self.root)): path = default break else: path = defaults[-1] - setattr( self, var + '_set', False ) - setattr( self, var, resolve_path( path, self.root ) ) + setattr(self, var + '_set', False) + setattr(self, var, resolve_path(path, self.root)) for var, defaults in listify_defaults.items(): paths = [] @@ -326,7 +326,7 @@ class GalaxyAppConfiguration(BaseAppConfiguration): self.oidc = [] # The value of migrated_tools_config is the file reserved for containing only those tools that have been eliminated from the distribution # and moved to the tool shed. It is created on demand. - self.integrated_tool_panel_config = resolve_path(kwargs.get('integrated_tool_panel_config', 'integrated_tool_panel.xml' ), self.mutable_config_dir) + self.integrated_tool_panel_config = resolve_path(kwargs.get('integrated_tool_panel_config', 'integrated_tool_panel.xml'), self.mutable_config_dir) integrated_tool_panel_tracking_directory = kwargs.get('integrated_tool_panel_tracking_directory', None) if integrated_tool_panel_tracking_directory: self.integrated_tool_panel_tracking_directory = resolve_path(integrated_tool_panel_tracking_directory, self.root) @@ -603,7 +603,7 @@ class GalaxyAppConfiguration(BaseAppConfiguration): self.tool_test_data_directories = kwargs.get("tool_test_data_directories", default_tool_test_data_directories) # Location for tool dependencies. use_tool_dependencies, tool_dependency_dir, use_cached_dependency_manager, tool_dependency_cache_dir, precache_dependencies = \ - parse_dependency_options(kwargs, self.root, self.dependency_resolvers_config_file) + parse_dependency_options(kwargs, self.data_dir, self.dependency_resolvers_config_file) self.use_tool_dependencies = use_tool_dependencies self.tool_dependency_dir = tool_dependency_dir self.use_cached_dependency_manager = use_cached_dependency_manager @@ -1064,7 +1064,7 @@ def parse_dependency_options(kwargs, root, dependency_resolvers_config_file): tool_dependency_dir = None if tool_dependency_dir is not None: - tool_dependency_dir = resolve_path(tool_dependency_dir, self.data_dir) + tool_dependency_dir = resolve_path(tool_dependency_dir, root) # Setting the following flag to true will ultimately cause tool dependencies # to be located in the shell environment and used by the job that is executing # the tool. diff --git a/lib/galaxy/config/script.py b/lib/galaxy/config/script.py index 7ac94097ab7..6cf211a890d 100644 --- a/lib/galaxy/config/script.py +++ b/lib/galaxy/config/script.py @@ -166,7 +166,7 @@ def _handle_galaxy_ini(args, config_dir, data_dir): galaxy_config_template = [] with open(GALAXY_CONFIG_TEMPLATE_FILE) as fh: - for line in [ l.rstrip('\n') for l in fh.readlines() ]: + for line in [l.rstrip('\n') for l in fh.readlines()]: for k, v in GALAXY_CONFIG_SUBSTITUTIONS.items(): if line == k: line = v diff --git a/lib/galaxy/model/orm/scripts.py b/lib/galaxy/model/orm/scripts.py index 62a17b22de4..b519897fd48 100644 --- a/lib/galaxy/model/orm/scripts.py +++ b/lib/galaxy/model/orm/scripts.py @@ -9,7 +9,7 @@ import sys from migrate.versioning.shell import main as migrate_main from galaxy.util.path import get_ext -from galaxy.util.properties import find_config_file, get_data_dir, load_app_properties, running_from_source +from galaxy.util.properties import find_config_file, get_data_dir, load_app_properties from galaxy.util.script import populate_config_args diff --git a/lib/galaxy/tools/special_tools.py b/lib/galaxy/tools/special_tools.py index 92f8a21830f..5665118bce2 100644 --- a/lib/galaxy/tools/special_tools.py +++ b/lib/galaxy/tools/special_tools.py @@ -1,5 +1,6 @@ -import os import logging +import os + log = logging.getLogger(__name__) SPECIAL_TOOLS = { diff --git a/lib/galaxy/web/framework/webapp.py b/lib/galaxy/web/framework/webapp.py index a0fca708765..5f42693649a 100644 --- a/lib/galaxy/web/framework/webapp.py +++ b/lib/galaxy/web/framework/webapp.py @@ -968,7 +968,7 @@ class GalaxyWebTransaction(base.DefaultWebTransaction, def default_url_path(path): - return os.path.abspath(os.path.join(os.path.dirname( __file__ ), path)) + return os.path.abspath(os.path.join(os.path.dirname(__file__), path)) def build_native_uwsgi_app(paste_factory, config_section): diff --git a/lib/tool_shed/galaxy_install/migrate/check.py b/lib/tool_shed/galaxy_install/migrate/check.py index 1afba56b375..f7a9c8747a6 100644 --- a/lib/tool_shed/galaxy_install/migrate/check.py +++ b/lib/tool_shed/galaxy_install/migrate/check.py @@ -57,7 +57,7 @@ def verify_tools(app, url, galaxy_config_file=None, engine_options={}): if tool_shed_accessible: # Automatically update the value of the migrate_tools.version database table column. # FIXME: this doesn't seem right. - manage_tools = os.path.abspath(os.path.join(os.path.dirname( __file__ ), 'scripts', 'manage_tools.py')) + manage_tools = os.path.abspath(os.path.join(os.path.dirname(__file__), 'scripts', 'manage_tools.py')) cmd = [executable, manage_tools, 'upgrade', 'tools'] if galaxy_config_file: cmd[2:2] = ['-c', galaxy_config_file] diff --git a/lib/tool_shed/galaxy_install/tool_migration_manager.py b/lib/tool_shed/galaxy_install/tool_migration_manager.py index 91455a1c5d0..5545b583d67 100644 --- a/lib/tool_shed/galaxy_install/tool_migration_manager.py +++ b/lib/tool_shed/galaxy_install/tool_migration_manager.py @@ -3,7 +3,6 @@ Manage automatic installation of tools configured in the xxx.xml files in ~/scri All of the tools were at some point included in the Galaxy distribution, but are now hosted in the main Galaxy tool shed. """ import errno -import json import logging import os import shutil @@ -72,7 +71,7 @@ class ToolMigrationManager(object): except (IOError, OSError) as exc: if exc.errno == errno.ENOENT: with open(migrated_tools_config, 'w') as fh: - fh.write( MIGRATED_TOOLS_CONF_XML.format(shed_tools_dir=self.app.config.shed_tools_dir)) + fh.write(MIGRATED_TOOLS_CONF_XML.format(shed_tools_dir=self.app.config.shed_tools_dir)) tree, error_message = xml_util.parse_xml(migrated_tools_config) else: raise diff --git a/lib/tool_shed/util/common_util.py b/lib/tool_shed/util/common_util.py index e61c2b5972e..7caeb00f18b 100644 --- a/lib/tool_shed/util/common_util.py +++ b/lib/tool_shed/util/common_util.py @@ -15,7 +15,7 @@ log = logging.getLogger(__name__) REPOSITORY_OWNER = 'devteam' TOOL_MIGRATION_SCRIPTS_DIR = os.path.abspath(os.path.join( os.path.dirname(__file__), os.pardir, 'galaxy_install', 'migrate', 'scripts')) -TOOL_MIGRATION_VERSIONS_DIR = os.path.abspath( os.path.join( +TOOL_MIGRATION_VERSIONS_DIR = os.path.abspath(os.path.join( os.path.dirname(__file__), os.pardir, 'galaxy_install', 'migrate', 'versions')) @@ -30,7 +30,7 @@ def accumulate_tool_dependencies(tool_shed_accessible, tool_dependencies, all_to def check_for_missing_tools(app, tool_panel_configs, latest_tool_migration_script_number): # Get the 000x_tools.xml file associated with the current migrate_tools version number. - tools_xml_file_path = os.path.abspath(os.path.join(os.path.dirname( __file__ ), + tools_xml_file_path = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'galaxy_install', 'migrate', 'scripts', '%04d_tools.xml' % latest_tool_migration_script_number)) diff --git a/setup.py b/setup.py index b879b8034eb..9256aea4117 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -from setuptools import setup, find_packages +from setuptools import find_packages, setup readme = open('README.rst').read()