1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/3116103966fa/ Changeset: 3116103966fa User: greg Date: 2013-12-03 17:01:20 Summary: Refactoring code cleanup for installing tool dependencies from the tool shed into Galaxy. Affected #: 4 files diff -r dd53fe2a3e7308ccd7a007f78ae6e29b7eff9ef0 -r 3116103966fa1cd6c942aa918bcd647f39c0aae3 lib/galaxy/model/__init__.py --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -3631,6 +3631,11 @@ return False @property + def is_deactivated_or_installed( self ): + return self.status in [ self.installation_status.DEACTIVATED, + self.installation_status.INSTALLED ] + + @property def is_latest_installable_revision( self ): if self.tool_shed_status: return galaxy.util.asbool( self.tool_shed_status.get( 'latest_installable_revision', False ) ) diff -r dd53fe2a3e7308ccd7a007f78ae6e29b7eff9ef0 -r 3116103966fa1cd6c942aa918bcd647f39c0aae3 lib/tool_shed/galaxy_install/tool_dependencies/fabric_util.py --- a/lib/tool_shed/galaxy_install/tool_dependencies/fabric_util.py +++ b/lib/tool_shed/galaxy_install/tool_dependencies/fabric_util.py @@ -37,11 +37,30 @@ def append_line( self, skip_if_contained=True, make_executable=True, **kwd ): env_var_dict = dict( **kwd ) - env_entry, env_file = td_common_util.create_or_update_env_shell_file( self.install_dir, env_var_dict ) + env_entry, env_file = self.create_or_update_env_shell_file( self.install_dir, env_var_dict ) return_code = file_append( env_entry, env_file, skip_if_contained=skip_if_contained, make_executable=make_executable ) self.return_code = self.return_code or return_code return self.return_code + def create_or_update_env_shell_file( self, install_dir, env_var_dict ): + env_var_action = env_var_dict[ 'action' ] + env_var_value = env_var_dict[ 'value' ] + if env_var_action in [ 'prepend_to', 'set_to', 'append_to' ]: + env_var_name = env_var_dict[ 'name' ] + if env_var_action == 'prepend_to': + changed_value = '%s:$%s' % ( env_var_value, env_var_name ) + elif env_var_action == 'set_to': + changed_value = '%s' % env_var_value + elif env_var_action == 'append_to': + changed_value = '$%s:%s' % ( env_var_name, env_var_value ) + line = "%s=%s; export %s" % ( env_var_name, changed_value, env_var_name ) + elif env_var_action == "source": + line = ". %s" % env_var_value + else: + raise Exception( "Unknown shell file action %s" % env_var_action ) + env_shell_file_path = os.path.join( install_dir, 'env.sh' ) + return line, env_shell_file_path + class InstallEnvironment( object ): """Object describing the environment built up as part of the process of building and installing a package.""" diff -r dd53fe2a3e7308ccd7a007f78ae6e29b7eff9ef0 -r 3116103966fa1cd6c942aa918bcd647f39c0aae3 lib/tool_shed/galaxy_install/tool_dependencies/install_util.py --- a/lib/tool_shed/galaxy_install/tool_dependencies/install_util.py +++ b/lib/tool_shed/galaxy_install/tool_dependencies/install_util.py @@ -216,7 +216,7 @@ if can_install_tool_dependency: # Set this dependent repository's tool dependency env.sh file with a path to the required repository's installed tool dependency package. # We can get everything we need from the discovered installed required_repository. - if required_repository.is_installed: + if required_repository.is_deactivated_or_installed: if not os.path.exists( required_repository_package_install_dir ): print 'Missing required tool dependency directory %s' % str( required_repository_package_install_dir ) repo_files_dir = required_repository.repo_files_directory( app ) @@ -848,20 +848,29 @@ type='set_environment', status=app.model.ToolDependency.installation_status.INSTALLING, set_status=True ) - env_entry, env_file = td_common_util.create_or_update_env_shell_file( install_dir, env_var_dict ) if env_var_version == '1.0': - # Handle setting environment variables using a fabric method. - fabric_util.file_append( env_entry, env_file, skip_if_contained=True, make_executable=True ) - sa_session.refresh( tool_dependency ) - if tool_dependency.status not in [ app.model.ToolDependency.installation_status.ERROR, - app.model.ToolDependency.installation_status.INSTALLED ]: + # Create this tool dependency's env.sh file. + env_file_builder = fabric_util.EnvFileBuilder( install_dir ) + return_code = env_file_builder.append_line( skip_if_contained=True, make_executable=True, **env_var_dict ) + if return_code: + error_message = 'Error creating env.sh file for tool dependency %s, return_code: %s' % \ + ( str( tool_dependency.name ), str( return_code ) ) + log.debug( error_message ) tool_dependency = tool_dependency_util.set_tool_dependency_attributes( app, tool_dependency=tool_dependency, - status=app.model.ToolDependency.installation_status.INSTALLED, - error_message=None, + status=app.model.ToolDependency.installation_status.ERROR, + error_message=error_message, remove_from_disk=False ) - log.debug( 'Environment variable %s set in %s for tool dependency %s.' % \ - ( str( env_var_name ), str( install_dir ), str( tool_dependency.name ) ) ) + else: + if tool_dependency.status not in [ app.model.ToolDependency.installation_status.ERROR, + app.model.ToolDependency.installation_status.INSTALLED ]: + tool_dependency = tool_dependency_util.set_tool_dependency_attributes( app, + tool_dependency=tool_dependency, + status=app.model.ToolDependency.installation_status.INSTALLED, + error_message=None, + remove_from_disk=False ) + log.debug( 'Environment variable %s set in %s for tool dependency %s.' % \ + ( str( env_var_name ), str( install_dir ), str( tool_dependency.name ) ) ) else: error_message = 'Only set_environment version 1.0 is currently supported (i.e., change your tag to be <set_environment version="1.0">).' tool_dependency = tool_dependency_util.set_tool_dependency_attributes( app, diff -r dd53fe2a3e7308ccd7a007f78ae6e29b7eff9ef0 -r 3116103966fa1cd6c942aa918bcd647f39c0aae3 lib/tool_shed/galaxy_install/tool_dependencies/td_common_util.py --- a/lib/tool_shed/galaxy_install/tool_dependencies/td_common_util.py +++ b/lib/tool_shed/galaxy_install/tool_dependencies/td_common_util.py @@ -145,25 +145,6 @@ return dict( name=env_var_name, action=env_var_action, value=elem.text) return None -def create_or_update_env_shell_file( install_dir, env_var_dict ): - env_var_action = env_var_dict[ 'action' ] - env_var_value = env_var_dict[ 'value' ] - if env_var_action in ['prepend_to', 'set_to', 'append_to']: - env_var_name = env_var_dict[ 'name' ] - if env_var_action == 'prepend_to': - changed_value = '%s:$%s' % ( env_var_value, env_var_name ) - elif env_var_action == 'set_to': - changed_value = '%s' % env_var_value - elif env_var_action == 'append_to': - changed_value = '$%s:%s' % ( env_var_name, env_var_value ) - line = "%s=%s; export %s" % ( env_var_name, changed_value, env_var_name ) - elif env_var_action == "source": - line = ". %s" % env_var_value - else: - raise Exception( "Unknown shell file action %s" % env_var_action ) - env_shell_file_path = os.path.join( install_dir, 'env.sh' ) - return line, env_shell_file_path - def download_binary( url, work_dir ): ''' Download a pre-compiled binary from the specified URL. Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.