1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/b9804f980783/ changeset: b9804f980783 user: greg date: 2012-07-05 23:44:01 summary: Fixes for simultaneously installing multiple tool shed repositories into a local Galaxy instance, and fixes for installing repositories retrieved from searches in the tool shed. affected #: 13 files diff -r 98204b9f4f806c15fa52fd728b5dacbc64f5eeb1 -r b9804f980783c4a014a66f7cf45979ae290e71f0 lib/galaxy/web/controllers/admin_toolshed.py --- a/lib/galaxy/web/controllers/admin_toolshed.py +++ b/lib/galaxy/web/controllers/admin_toolshed.py @@ -558,21 +558,15 @@ message = kwd.get( 'message', '' ) status = kwd.get( 'status', 'done' ) tool_shed_url = kwd[ 'tool_shed_url' ] + # The value of repo_info_dicts is a list of one or more dictionaries, each associated with a tool shed repository that will be installed. + encoded_repo_info_dicts = util.listify( kwd[ 'repo_info_dicts' ] ) + repo_info_dicts = [ tool_shed_decode( repo_info_dict ) for repo_info_dict in encoded_repo_info_dicts ] + # Every repository will be installed into the same tool panel section or all will be installed outside of any sections. new_tool_panel_section = kwd.get( 'new_tool_panel_section', '' ) tool_panel_section = kwd.get( 'tool_panel_section', '' ) + # One or more repositories may include tools, but not necessarily all of them. includes_tools = util.string_as_bool( kwd.get( 'includes_tools', False ) ) includes_tool_dependencies = util.string_as_bool( kwd.get( 'includes_tool_dependencies', False ) ) - if includes_tool_dependencies: - dict_with_tool_dependencies = tool_shed_decode( kwd[ 'repo_info_dict' ] ) - # The repo_info_dict includes tool dependencies which we need to display so the user knows what will be installed. - repo_info_dict = {} - for name, repo_info_tuple in dict_with_tool_dependencies.items(): - description, repository_clone_url, changeset_revision, ctx_rev, repository_owner, tool_dependencies = repo_info_tuple - # Create a new repo_info_dict by eliminating tool_dependencies from the repo_info_tuple. - repo_info_dict[ name ] = ( description, repository_clone_url, changeset_revision, ctx_rev ) - else: - dict_with_tool_dependencies = {} - repo_info_dict = tool_shed_decode( kwd[ 'repo_info_dict' ] ) install_tool_dependencies = kwd.get( 'install_tool_dependencies', '' ) tool_section = None if not includes_tools or ( includes_tools and kwd.get( 'select_tool_panel_section_button', False ) ): @@ -597,50 +591,51 @@ break # Make sure all tool_shed_repository records exist. created_or_updated_tool_shed_repositories = [] - for name, repo_info_tuple in repo_info_dict.items(): - description, repository_clone_url, changeset_revision, ctx_rev = repo_info_tuple - clone_dir = os.path.join( tool_path, self.generate_tool_path( repository_clone_url, changeset_revision ) ) - relative_install_dir = os.path.join( clone_dir, name ) - owner = get_repository_owner( clean_repository_clone_url( repository_clone_url ) ) - # Make sure the repository was not already installed. - installed_tool_shed_repository, installed_changeset_revision = self.repository_was_previously_installed( trans, - tool_shed_url, - name, - repo_info_tuple, - clone_dir ) - if installed_tool_shed_repository: - message = "The tool shed repository <b>%s</b> with owner <b>%s</b> and changeset revision <b>%s</b> " % ( name, owner, changeset_revision ) - if installed_changeset_revision != changeset_revision: - message += "was previously installed using changeset revision <b>%s</b>. " % installed_changeset_revision + for repo_info_dict in repo_info_dicts: + for name, repo_info_tuple in repo_info_dict.items(): + description, repository_clone_url, changeset_revision, ctx_rev, repository_owner, tool_dependencies = repo_info_tuple + clone_dir = os.path.join( tool_path, self.generate_tool_path( repository_clone_url, changeset_revision ) ) + relative_install_dir = os.path.join( clone_dir, name ) + owner = get_repository_owner( clean_repository_clone_url( repository_clone_url ) ) + # Make sure the repository was not already installed. + installed_tool_shed_repository, installed_changeset_revision = self.repository_was_previously_installed( trans, + tool_shed_url, + name, + repo_info_tuple, + clone_dir ) + if installed_tool_shed_repository: + message += "The tool shed repository <b>%s</b> with owner <b>%s</b> and changeset revision <b>%s</b> " % ( name, owner, changeset_revision ) + if installed_changeset_revision != changeset_revision: + message += "was previously installed using changeset revision <b>%s</b>. " % installed_changeset_revision + else: + message += "was previously installed. " + if installed_tool_shed_repository.uninstalled: + message += "The repository has been uninstalled, however, so reinstall the original repository instead of installing it again. " + elif installed_tool_shed_repository.deleted: + message += "The repository has been deactivated, however, so activate the original repository instead of installing it again. " + if installed_changeset_revision != changeset_revision: + message += "You can get the latest updates for the repository using the <b>Get updates</b> option from the repository's " + message += "<b>Repository Actions</b> pop-up menu. " + status = 'error' + if len( repo_info_dicts ) == 1: + new_kwd = dict( message=message, status=status ) + return trans.response.send_redirect( web.url_for( controller='admin_toolshed', + action='browse_repositories', + **new_kwd ) ) else: - message += "was previously installed. " - if installed_tool_shed_repository.uninstalled: - message += "The repository has been uninstalled, however, so reinstall the original repository instead of installing it again. " - elif installed_tool_shed_repository.deleted: - message += "The repository has been deactivated, however, so activate the original repository instead of installing it again. " - if installed_changeset_revision != changeset_revision: - message += "You can get the latest updates for the repository using the <b>Get updates</b> option from the repository's " - message += "<b>Repository Actions</b> pop-up menu. " - status = 'error' - if len( repo_info_dict ) == 1: - new_kwd = dict( message=message, status=status ) - return trans.response.send_redirect( web.url_for( controller='admin_toolshed', - action='browse_repositories', - **new_kwd ) ) - else: - print "Adding new row (or updating an existing row) for repository '%s' in the tool_shed_repository table." % name - tool_shed_repository = create_or_update_tool_shed_repository( app=trans.app, - name=name, - description=description, - installed_changeset_revision=changeset_revision, - ctx_rev=ctx_rev, - repository_clone_url=repository_clone_url, - metadata_dict={}, - status=trans.model.ToolShedRepository.installation_status.NEW, - current_changeset_revision=changeset_revision, - owner=owner, - dist_to_shed=False ) - created_or_updated_tool_shed_repositories.append( tool_shed_repository ) + print "Adding new row (or updating an existing row) for repository '%s' in the tool_shed_repository table." % name + tool_shed_repository = create_or_update_tool_shed_repository( app=trans.app, + name=name, + description=description, + installed_changeset_revision=changeset_revision, + ctx_rev=ctx_rev, + repository_clone_url=repository_clone_url, + metadata_dict={}, + status=trans.model.ToolShedRepository.installation_status.NEW, + current_changeset_revision=changeset_revision, + owner=owner, + dist_to_shed=False ) + created_or_updated_tool_shed_repositories.append( tool_shed_repository ) if created_or_updated_tool_shed_repositories: if includes_tools and ( new_tool_panel_section or tool_panel_section ): if new_tool_panel_section: @@ -669,7 +664,7 @@ new_kwd = dict( includes_tool_dependencies=kwd.get( 'includes_tool_dependencies', False ), includes_tools=kwd.get( 'includes_tools', False ), install_tool_dependencies=install_tool_dependencies, - repo_info_dict=kwd[ 'repo_info_dict' ], + repo_info_dicts=kwd[ 'repo_info_dicts' ], message=message, new_tool_panel_section=kwd.get( 'new_tool_panel_section', '' ), shed_tool_conf=kwd[ 'shed_tool_conf' ], @@ -701,12 +696,12 @@ shed_tool_conf = shed_tool_conf.replace( './', '', 1 ) shed_tool_conf_select_field = None tool_panel_section_select_field = build_tool_panel_section_select_field( trans ) - if includes_tools and len( repo_info_dict ) == 1: + if includes_tools and len( repo_info_dicts ) == 1: # If we're installing a single repository that contains a readme file, get it's contents to display. + repo_info_dict = repo_info_dicts[ 0 ] name = repo_info_dict.keys()[ 0 ] repo_info_tuple = repo_info_dict[ name ] - description, repository_clone_url, changeset_revision, ctx_rev = repo_info_tuple - repository_owner = get_repository_owner( clean_repository_clone_url( repository_clone_url ) ) + description, repository_clone_url, changeset_revision, ctx_rev, repository_owner, tool_dependencies = repo_info_tuple url = '%srepository/get_readme?name=%s&owner=%s&changeset_revision=%s&webapp=galaxy&no_reset=true' % \ ( tool_shed_url, name, repository_owner, changeset_revision ) response = urllib2.urlopen( url ) @@ -724,8 +719,8 @@ install_tool_dependencies_check_box = CheckboxField( 'install_tool_dependencies', checked=True ) return trans.fill_template( '/admin/tool_shed_repository/select_tool_panel_section.mako', tool_shed_url=tool_shed_url, - repo_info_dict=kwd[ 'repo_info_dict' ], - dict_with_tool_dependencies=dict_with_tool_dependencies, + encoded_repo_info_dicts=kwd[ 'repo_info_dicts' ], + repo_info_dicts=repo_info_dicts, shed_tool_conf=shed_tool_conf, includes_tools=includes_tools, includes_tool_dependencies=includes_tool_dependencies, @@ -781,7 +776,8 @@ @web.require_admin def install_tool_shed_repositories( self, trans, tool_shed_repositories, reinstalling=False, **kwd ): """Install specified tool shed repositories.""" - repo_info_dict = tool_shed_decode( kwd[ 'repo_info_dict' ] ) + encoded_repo_info_dicts = util.listify( kwd[ 'repo_info_dicts' ] ) + repo_info_dicts = [ tool_shed_decode( repo_info_dict ) for repo_info_dict in encoded_repo_info_dicts ] tool_path = kwd[ 'tool_path' ] includes_tool_dependencies = util.string_as_bool( kwd[ 'includes_tool_dependencies' ] ) install_tool_dependencies = CheckboxField.is_checked( kwd.get( 'install_tool_dependencies', '' ) ) @@ -790,14 +786,11 @@ tool_section = trans.app.toolbox.tool_panel[ tool_panel_section_key ] else: tool_section = None - for tool_shed_repository in tool_shed_repositories: + for tool_shed_repository, repo_info_dict in zip( tool_shed_repositories, repo_info_dicts ): # Clone each repository to the configured location. update_tool_shed_repository_status( trans.app, tool_shed_repository, trans.model.ToolShedRepository.installation_status.CLONING ) repo_info_tuple = repo_info_dict[ tool_shed_repository.name ] - if includes_tool_dependencies and not reinstalling: - description, repository_clone_url, changeset_revision, ctx_rev, repository_owner, tool_dependencies = repo_info_tuple - else: - description, repository_clone_url, changeset_revision, ctx_rev = repo_info_tuple + description, repository_clone_url, changeset_revision, ctx_rev, repository_owner, tool_dependencies = repo_info_tuple clone_dir = os.path.join( tool_path, self.generate_tool_path( repository_clone_url, tool_shed_repository.installed_changeset_revision ) ) relative_install_dir = os.path.join( clone_dir, tool_shed_repository.name ) clone_repository( repository_clone_url, os.path.abspath( relative_install_dir ), ctx_rev ) @@ -858,38 +851,38 @@ shutil.rmtree( work_dir ) except: pass - if 'datatypes' in metadata: - update_tool_shed_repository_status( trans.app, - tool_shed_repository, - trans.model.ToolShedRepository.installation_status.LOADING_PROPRIETARY_DATATYPES ) - work_dir = make_tmp_directory() - datatypes_config = get_config_from_repository( trans.app, - 'datatypes_conf.xml', - tool_shed_repository, - tool_shed_repository.installed_changeset_revision, - work_dir ) - # Load proprietary data types required by tools. - converter_path, display_path = alter_config_and_load_prorietary_datatypes( trans.app, datatypes_config, relative_install_dir, override=False ) - if converter_path or display_path: - # Create a dictionary of tool shed repository related information. - repository_dict = create_repository_dict_for_proprietary_datatypes( tool_shed=self.tool_shed, - name=tool_shed_repository.name, - owner=tool_shed_repository.owner, - installed_changeset_revision=tool_shed_repository.installed_changeset_revision, - tool_dicts=metadata.get( 'tools', [] ), - converter_path=converter_path, - display_path=display_path ) - if converter_path: - # Load proprietary datatype converters - trans.app.datatypes_registry.load_datatype_converters( trans.app.toolbox, installed_repository_dict=repository_dict ) - if display_path: - # Load proprietary datatype display applications - trans.app.datatypes_registry.load_display_applications( installed_repository_dict=repository_dict ) - try: - shutil.rmtree( work_dir ) - except: - pass - update_tool_shed_repository_status( trans.app, tool_shed_repository, trans.model.ToolShedRepository.installation_status.INSTALLED ) + if 'datatypes' in metadata: + update_tool_shed_repository_status( trans.app, + tool_shed_repository, + trans.model.ToolShedRepository.installation_status.LOADING_PROPRIETARY_DATATYPES ) + work_dir = make_tmp_directory() + datatypes_config = get_config_from_repository( trans.app, + 'datatypes_conf.xml', + tool_shed_repository, + tool_shed_repository.installed_changeset_revision, + work_dir ) + # Load proprietary data types required by tools. + converter_path, display_path = alter_config_and_load_prorietary_datatypes( trans.app, datatypes_config, relative_install_dir, override=False ) + if converter_path or display_path: + # Create a dictionary of tool shed repository related information. + repository_dict = create_repository_dict_for_proprietary_datatypes( tool_shed=self.tool_shed, + name=tool_shed_repository.name, + owner=tool_shed_repository.owner, + installed_changeset_revision=tool_shed_repository.installed_changeset_revision, + tool_dicts=metadata.get( 'tools', [] ), + converter_path=converter_path, + display_path=display_path ) + if converter_path: + # Load proprietary datatype converters + trans.app.datatypes_registry.load_datatype_converters( trans.app.toolbox, installed_repository_dict=repository_dict ) + if display_path: + # Load proprietary datatype display applications + trans.app.datatypes_registry.load_display_applications( installed_repository_dict=repository_dict ) + try: + shutil.rmtree( work_dir ) + except: + pass + update_tool_shed_repository_status( trans.app, tool_shed_repository, trans.model.ToolShedRepository.installation_status.INSTALLED ) tsr_ids_for_monitoring = [ trans.security.encode_id( tsr.id ) for tsr in tool_shed_repositories ] return trans.response.send_redirect( web.url_for( controller='admin_toolshed', action='monitor_repository_installation', @@ -1241,7 +1234,7 @@ new_kwd = dict( includes_tool_dependencies=tool_shed_repository.includes_tool_dependencies, includes_tools=tool_shed_repository.includes_tools, install_tool_dependencies=install_tool_dependencies, - repo_info_dict=kwd[ 'repo_info_dict' ], + repo_info_dicts=kwd[ 'repo_info_dict' ], message=message, new_tool_panel_section=new_tool_panel_section, shed_tool_conf=shed_tool_conf, @@ -1282,8 +1275,7 @@ # Handle case where the repository was previously installed using an older changeset_revsion, but later the repository was updated # in the tool shed and now we're trying to install the latest changeset revision of the same repository instead of updating the one # that was previously installed. We'll look in the database instead of on disk since the repository may be uninstalled. - description, repository_clone_url, changeset_revision, ctx_rev = repo_info_tuple - repository_owner = get_repository_owner( clean_repository_clone_url( repository_clone_url ) ) + description, repository_clone_url, changeset_revision, ctx_rev, repository_owner, tool_dependencies = repo_info_tuple tool_shed = get_tool_shed_from_clone_url( repository_clone_url ) # Get all previous change set revisions from the tool shed for the repository back to, but excluding, the previous valid changeset # revision to see if it was previously installed using one of them. @@ -1309,22 +1301,16 @@ def reselect_tool_panel_section( self, trans, **kwd ): repository = get_repository( trans, kwd[ 'id' ] ) metadata = repository.metadata - # Populate repo_info_dict. tool_shed_url = get_url_from_repository_tool_shed( trans.app, repository ) ctx_rev = get_ctx_rev( tool_shed_url, repository.name, repository.owner, repository.installed_changeset_revision ) repository_clone_url = generate_clone_url( trans, repository ) repo_info_dict = {} - repo_info_dict[ repository.name ] = ( repository.description, repository_clone_url, repository.installed_changeset_revision, ctx_rev ) - dict_with_tool_dependencies = {} - includes_tool_dependencies = repository.includes_tool_dependencies - if includes_tool_dependencies: - # Populate dict_with_tool_dependencies. - dict_with_tool_dependencies[ repository.name ] = ( repository.description, - repository_clone_url, - repository.installed_changeset_revision, - ctx_rev, - repository.owner, - metadata[ 'tool_dependencies' ] ) + repo_info_dict[ repository.name ] = ( repository.description, + repository_clone_url, + repository.installed_changeset_revision, + ctx_rev, + repository.owner, + metadata.get( 'tool_dependencies', None ) ) # Get the location in the tool panel in which the tool was originally loaded. if 'tool_panel_section' in metadata: tool_panel_dict = metadata[ 'tool_panel_section' ] @@ -1360,7 +1346,6 @@ install_tool_dependencies_check_box=install_tool_dependencies_check_box, tool_panel_section_select_field=tool_panel_section_select_field, repo_info_dict=tool_shed_encode( repo_info_dict ), - dict_with_tool_dependencies=dict_with_tool_dependencies, includes_tool_dependencies=includes_tool_dependencies, message=message, status=status ) diff -r 98204b9f4f806c15fa52fd728b5dacbc64f5eeb1 -r b9804f980783c4a014a66f7cf45979ae290e71f0 lib/galaxy/webapps/community/controllers/common.py --- a/lib/galaxy/webapps/community/controllers/common.py +++ b/lib/galaxy/webapps/community/controllers/common.py @@ -381,27 +381,6 @@ repository_metadata.downloadable = changeset_is_downloadable( metadata_dict ) trans.sa_session.add( repository_metadata ) trans.sa_session.flush() -def decode( value ): - # Extract and verify hash - a, b = value.split( ":" ) - value = binascii.unhexlify( b ) - test = hmac_new( 'ToolShedAndGalaxyMustHaveThisSameKey', value ) - assert a == test - # Restore from string - try: - values = json_fix( simplejson.loads( value ) ) - except Exception, e: - # We do not have a json string - values = value - return values -def encode( val ): - if isinstance( val, dict ): - value = simplejson.dumps( val ) - else: - value = val - a = hmac_new( 'ToolShedAndGalaxyMustHaveThisSameKey', value ) - b = binascii.hexlify( value ) - return "%s:%s" % ( a, b ) def generate_clone_url( trans, repository_id ): """Generate the URL for cloning a repository.""" repository = get_repository( trans, repository_id ) diff -r 98204b9f4f806c15fa52fd728b5dacbc64f5eeb1 -r b9804f980783c4a014a66f7cf45979ae290e71f0 lib/galaxy/webapps/community/controllers/repository.py --- a/lib/galaxy/webapps/community/controllers/repository.py +++ b/lib/galaxy/webapps/community/controllers/repository.py @@ -819,13 +819,16 @@ trans.sa_session.flush() download_url = '/repos/%s/%s/archive/%s' % ( repository.user.username, repository.name, file_type_str ) return trans.response.send_redirect( download_url ) - def __encode_repo_info_dict( self, trans, webapp, repository_metadata_ids ): + def __encode_repo_info_dict( self, trans, repository_metadata_ids ): repo_info_dict = {} includes_tools = False - for repository_metadata_id in repository_metadata_ids: + includes_tool_dependencies = False + for repository_metadata_id in util.listify( repository_metadata_ids ): repository_metadata = get_repository_metadata_by_id( trans, repository_metadata_id ) if not includes_tools and 'tools' in repository_metadata.metadata: includes_tools = True + if not includes_tool_dependencies and 'tool_dependencies' in repository_metadata.metadata: + includes_tool_dependencies = True repository = get_repository( trans, trans.security.encode_id( repository_metadata.repository_id ) ) # Get the changelog rev for this changeset_revision. repo_dir = repository.repo_path @@ -834,8 +837,11 @@ ctx = get_changectx_for_changeset( repo, changeset_revision ) repository_id = trans.security.encode_id( repository.id ) repository_clone_url = generate_clone_url( trans, repository_id ) - repo_info_dict[ repository.name ] = ( repository.description, repository_clone_url, changeset_revision, str( ctx.rev() ) ) - return encode( repo_info_dict ), includes_tools + if includes_tool_dependencies: + repo_info_dict[ repository.name ] = ( repository.description, repository_clone_url, changeset_revision, str( ctx.rev() ) ) + else: + repo_info_dict[ repository.name ] = ( repository.description, repository_clone_url, changeset_revision, str( ctx.rev() ) ) + return tool_shed_encode( repo_info_dict ), includes_tools, includes_tool_dependencies @web.expose def find_tools( self, trans, **kwd ): params = util.Params( kwd ) @@ -865,11 +871,17 @@ action=a, **kwd ) ) if operation == "install": - galaxy_url = trans.get_cookie( name='toolshedgalaxyurl' ) - encoded_repo_info_dict, includes_tools = self.__encode_repo_info_dict( trans, webapp, util.listify( item_id ) ) - url = '%sadmin_toolshed/install_repository?tool_shed_url=%s&webapp=%s&repo_info_dict=%s&includes_tools=%s' % \ - ( galaxy_url, url_for( '/', qualified=True ), webapp, encoded_repo_info_dict, str( includes_tools ) ) - return trans.response.send_redirect( url ) + # We've received a list of RepositoryMetadata ids, so we need to build a list of associated Repository ids. + encoded_repository_ids = [] + changeset_revisions = [] + for repository_metadata_id in util.listify( item_id ): + repository_metadata = get_repository_metadata_by_id( trans, repository_metadata_id ) + encoded_repository_ids.append( trans.security.encode_id( repository_metadata.repository.id ) ) + changeset_revisions.append( repository_metadata.changeset_revision ) + return trans.response.send_redirect( web.url_for( controller='repository', + action='install_repositories_by_revision', + repository_ids=encoded_repository_ids, + changeset_revisions=changeset_revisions ) ) else: # This can only occur when there is a multi-select grid with check boxes and an operation, # and the user clicked the operation button without checking any of the check boxes. @@ -945,11 +957,17 @@ action=a, **kwd ) ) if operation == "install": - galaxy_url = trans.get_cookie( name='toolshedgalaxyurl' ) - encoded_repo_info_dict, includes_tools = self.__encode_repo_info_dict( trans, webapp, util.listify( item_id ) ) - url = '%sadmin_toolshed/install_repository?tool_shed_url=%s&webapp=%s&repo_info_dict=%s&includes_tools=%s' % \ - ( galaxy_url, url_for( '/', qualified=True ), webapp, encoded_repo_info_dict, str( includes_tools ) ) - return trans.response.send_redirect( url ) + # We've received a list of RepositoryMetadata ids, so we need to build a list of associated Repository ids. + encoded_repository_ids = [] + changeset_revisions = [] + for repository_metadata_id in util.listify( item_id ): + repository_metadata = get_repository_metadata_by_id( trans, item_id ) + encoded_repository_ids.append( trans.security.encode_id( repository_metadata.repository.id ) ) + changeset_revisions.append( repository_metadata.changeset_revision ) + return trans.response.send_redirect( web.url_for( controller='repository', + action='install_repositories_by_revision', + repository_ids=encoded_repository_ids, + changeset_revisions=changeset_revisions ) ) else: # This can only occur when there is a multi-select grid with check boxes and an operation, # and the user clicked the operation button without checking any of the check boxes. @@ -1199,41 +1217,46 @@ message=message, status=status ) @web.expose - def install_repository_revision( self, trans, repository_id, **kwd ): + def install_repositories_by_revision( self, trans, repository_ids, changeset_revisions, **kwd ): + """Install a list of repositories into a local Galaxy instance by a specified changeset revision for each.""" params = util.Params( kwd ) message = util.restore_text( params.get( 'message', '' ) ) status = params.get( 'status', 'done' ) webapp = get_webapp( trans, **kwd ) galaxy_url = trans.get_cookie( name='toolshedgalaxyurl' ) - repository_clone_url = generate_clone_url( trans, repository_id ) - repository = get_repository( trans, repository_id ) - changeset_revision = util.restore_text( params.get( 'changeset_revision', repository.tip ) ) - repository_metadata = get_repository_metadata_by_changeset_revision( trans, repository_id, changeset_revision ) - metadata = repository_metadata.metadata - # Tell the caller if the repository includes Galaxy tools so the page enabling selection of the tool panel section can be displayed. - includes_tools = 'tools' in metadata - includes_tool_dependencies = 'tool_dependencies' in metadata - # Get the changelog rev for this changeset_revision. - repo_dir = repository.repo_path - repo = hg.repository( get_configured_ui(), repo_dir ) - ctx = get_changectx_for_changeset( repo, changeset_revision ) - repo_info_dict = {} - if includes_tool_dependencies: + repo_info_dicts = [] + includes_tools = False + includes_tool_dependencies = False + for repository_id, changeset_revision in zip( util.listify( repository_ids ), util.listify( changeset_revisions ) ): + repository_clone_url = generate_clone_url( trans, repository_id ) + repository = get_repository( trans, repository_id ) + #changeset_revision = util.restore_text( params.get( 'changeset_revision', repository.tip ) ) + repository_metadata = get_repository_metadata_by_changeset_revision( trans, repository_id, changeset_revision ) + metadata = repository_metadata.metadata + # Tell the caller if the repository includes Galaxy tools so the page enabling selection of the tool panel section can be displayed. + if not includes_tools and 'tools' in metadata: + includes_tools = True + if not includes_tool_dependencies and 'tool_dependencies' in metadata: + includes_tool_dependencies = True + # Get the changelog rev for this changeset_revision. + repo_dir = repository.repo_path + repo = hg.repository( get_configured_ui(), repo_dir ) + ctx = get_changectx_for_changeset( repo, changeset_revision ) + repo_info_dict = {} repo_info_dict[ repository.name ] = ( repository.description, repository_clone_url, changeset_revision, str( ctx.rev() ), repository.user.username, - metadata[ 'tool_dependencies' ] ) - else: - repo_info_dict[ repository.name ] = ( repository.description, - repository_clone_url, - changeset_revision, - str( ctx.rev() ) ) - encoded_repo_info_dict = encode( repo_info_dict ) + metadata.get( 'tool_dependencies', None ) ) + repo_info_dicts.append( tool_shed_encode( repo_info_dict ) ) + encoded_repo_info_dicts = ','.join( repo_info_dicts ) # Redirect back to local Galaxy to perform install. - url = '%sadmin_toolshed/install_repository?tool_shed_url=%s&repo_info_dict=%s&includes_tools=%s&includes_tool_dependencies=%s' % \ - ( galaxy_url, url_for( '/', qualified=True ), encoded_repo_info_dict, str( includes_tools ), str( includes_tool_dependencies ) ) + url = '%sadmin_toolshed/install_repository' % galaxy_url + url += '?tool_shed_url=%s' % url_for( '/', qualified=True ) + url += '&repo_info_dicts=%s' % encoded_repo_info_dicts + url += '&includes_tools=%s' % includes_tools + url += '&includes_tool_dependencies=%s' % includes_tool_dependencies return trans.response.send_redirect( url ) @web.expose def load_invalid_tool( self, trans, repository_id, tool_config, changeset_revision, **kwd ): diff -r 98204b9f4f806c15fa52fd728b5dacbc64f5eeb1 -r b9804f980783c4a014a66f7cf45979ae290e71f0 lib/galaxy/webapps/community/controllers/workflow.py --- a/lib/galaxy/webapps/community/controllers/workflow.py +++ b/lib/galaxy/webapps/community/controllers/workflow.py @@ -10,6 +10,7 @@ from galaxy.web.controllers.workflow import attach_ordered_steps from galaxy.model.orm import * from common import * +from galaxy.tool_shed.encoding_util import * class RepoInputDataModule( InputDataModule ): @@ -139,7 +140,7 @@ repository_metadata_id = kwd.get( 'repository_metadata_id', '' ) workflow_name = kwd.get( 'workflow_name', '' ) if workflow_name: - workflow_name = decode( workflow_name ) + workflow_name = tool_shed_decode( workflow_name ) webapp = kwd.get( 'webapp', 'community' ) message = kwd.get( 'message', '' ) status = kwd.get( 'status', 'done' ) @@ -159,7 +160,7 @@ repository_id = trans.security.encode_id( repository_metadata.repository_id ) changeset_revision = repository_metadata.changeset_revision metadata = repository_metadata.metadata - workflow_name = decode( workflow_name ) + workflow_name = tool_shed_decode( workflow_name ) # metadata[ 'workflows' ] is a list of tuples where each contained tuple is # [ <relative path to the .ga file in the repository>, <exported workflow dict> ] for workflow_tup in metadata[ 'workflows' ]: @@ -385,7 +386,7 @@ repository_metadata_id = kwd.get( 'repository_metadata_id', '' ) workflow_name = kwd.get( 'workflow_name', '' ) if workflow_name: - workflow_name = decode( workflow_name ) + workflow_name = tool_shed_decode( workflow_name ) webapp = kwd.get( 'webapp', 'community' ) message = kwd.get( 'message', '' ) status = kwd.get( 'status', 'done' ) @@ -403,7 +404,7 @@ return open( tmp_fname ) galaxy_url = trans.get_cookie( name='toolshedgalaxyurl' ) url = '%sworkflow/import_workflow?tool_shed_url=%s&repository_metadata_id=%s&workflow_name=%s&webapp=%s' % \ - ( galaxy_url, url_for( '/', qualified=True ), repository_metadata_id, encode( workflow_name ), webapp ) + ( galaxy_url, url_for( '/', qualified=True ), repository_metadata_id, tool_shed_encode( workflow_name ), webapp ) return trans.response.send_redirect( url ) return trans.response.send_redirect( web.url_for( controller='workflow', action='view_workflow', diff -r 98204b9f4f806c15fa52fd728b5dacbc64f5eeb1 -r b9804f980783c4a014a66f7cf45979ae290e71f0 templates/admin/tool_shed_repository/common.mako --- a/templates/admin/tool_shed_repository/common.mako +++ b/templates/admin/tool_shed_repository/common.mako @@ -67,7 +67,7 @@ </script></%def> -<%def name="render_tool_dependency_section( install_tool_dependencies_check_box, dict_with_tool_dependencies )"> +<%def name="render_tool_dependency_section( install_tool_dependencies_check_box, repo_info_dicts )"><% import os %><div class="form-row"><div class="toolParamHelp" style="clear: both;"> @@ -100,32 +100,36 @@ <th>Type</th><th>Install directory</th></tr> - %for repository_name, repo_info_tuple in dict_with_tool_dependencies.items(): - <% description, repository_clone_url, changeset_revision, ctx_rev, repository_owner, tool_dependencies = repo_info_tuple %> - %for dependency_key, requirements_dict in tool_dependencies.items(): - <% - name = requirements_dict[ 'name' ] - version = requirements_dict[ 'version' ] - type = requirements_dict[ 'type' ] - install_dir = os.path.join( trans.app.config.tool_dependency_dir, - name, - version, - repository_owner, - repository_name, - changeset_revision ) - tool_dependency_readme_text = requirements_dict.get( 'readme', None ) - %> - %if not os.path.exists( install_dir ): - <tr> - <td>${name}</td> - <td>${version}</td> - <td>${type}</td> - <td>${install_dir}</td> - </tr> - %if tool_dependency_readme_text: - <tr><td colspan="4" bgcolor="#FFFFCC">${name} ${version} requirements and installation information</td></tr> - <tr><td colspan="4"><pre>${tool_dependency_readme_text}</pre></td></tr> - %endif + %for repo_info_dict in repo_info_dicts: + %for repository_name, repo_info_tuple in repo_info_dict.items(): + <% description, repository_clone_url, changeset_revision, ctx_rev, repository_owner, tool_dependencies = repo_info_tuple %> + %if tool_dependencies: + %for dependency_key, requirements_dict in tool_dependencies.items(): + <% + name = requirements_dict[ 'name' ] + version = requirements_dict[ 'version' ] + type = requirements_dict[ 'type' ] + install_dir = os.path.join( trans.app.config.tool_dependency_dir, + name, + version, + repository_owner, + repository_name, + changeset_revision ) + tool_dependency_readme_text = requirements_dict.get( 'readme', None ) + %> + %if not os.path.exists( install_dir ): + <tr> + <td>${name}</td> + <td>${version}</td> + <td>${type}</td> + <td>${install_dir}</td> + </tr> + %if tool_dependency_readme_text: + <tr><td colspan="4" bgcolor="#FFFFCC">${name} ${version} requirements and installation information</td></tr> + <tr><td colspan="4"><pre>${tool_dependency_readme_text}</pre></td></tr> + %endif + %endif + %endfor %endif %endfor %endfor diff -r 98204b9f4f806c15fa52fd728b5dacbc64f5eeb1 -r b9804f980783c4a014a66f7cf45979ae290e71f0 templates/admin/tool_shed_repository/reselect_tool_panel_section.mako --- a/templates/admin/tool_shed_repository/reselect_tool_panel_section.mako +++ b/templates/admin/tool_shed_repository/reselect_tool_panel_section.mako @@ -12,7 +12,7 @@ <form name="reselect_tool_panel_section" id="reselect_tool_panel_section" action="${h.url_for( controller='admin_toolshed', action='reinstall_repository', id=trans.security.encode_id( repository.id ), repo_info_dict=repo_info_dict )}" method="post" ><div style="clear: both"></div> %if includes_tool_dependencies: - ${render_tool_dependency_section( install_tool_dependencies_check_box, dict_with_tool_dependencies )} + ${render_tool_dependency_section( install_tool_dependencies_check_box, [ repo_info_dict ] )} %endif <div style="clear: both"></div><div class="form-row"> diff -r 98204b9f4f806c15fa52fd728b5dacbc64f5eeb1 -r b9804f980783c4a014a66f7cf45979ae290e71f0 templates/admin/tool_shed_repository/select_tool_panel_section.mako --- a/templates/admin/tool_shed_repository/select_tool_panel_section.mako +++ b/templates/admin/tool_shed_repository/select_tool_panel_section.mako @@ -23,19 +23,23 @@ <br/><div class="toolForm"> - <div class="toolFormTitle">Confirm tool dependency installation</div> + %if includes_tool_dependencies: + <div class="toolFormTitle">Confirm tool dependency installation</div> + %else: + <div class="toolFormTitle">Choose the tool panel section to contain the installed tools (optional)</div> + %endif <div class="toolFormBody"> - <form name="select_tool_panel_section" id="select_tool_panel_section" action="${h.url_for( controller='admin_toolshed', action='install_repository', tool_shed_url=tool_shed_url, repo_info_dict=repo_info_dict, includes_tools=includes_tools, includes_tool_dependencies=includes_tool_dependencies )}" method="post" > + <form name="select_tool_panel_section" id="select_tool_panel_section" action="${h.url_for( controller='admin_toolshed', action='install_repository', tool_shed_url=tool_shed_url, repo_info_dicts=encoded_repo_info_dicts, includes_tools=includes_tools, includes_tool_dependencies=includes_tool_dependencies )}" method="post" ><div style="clear: both"></div> %if includes_tool_dependencies: - ${render_tool_dependency_section( install_tool_dependencies_check_box, dict_with_tool_dependencies )} + ${render_tool_dependency_section( install_tool_dependencies_check_box, repo_info_dicts )} + <div style="clear: both"></div> + <div class="form-row"> + <table class="colored" width="100%"> + <th bgcolor="#EBD9B2">Choose the tool panel section to contain the installed tools (optional)</th> + </table> + </div> %endif - <div style="clear: both"></div> - <div class="form-row"> - <table class="colored" width="100%"> - <th bgcolor="#EBD9B2">Choose the tool panel section to contain the installed tools (optional)</th> - </table> - </div> %if shed_tool_conf_select_field: <div class="form-row"><label>Shed tool configuration file:</label> diff -r 98204b9f4f806c15fa52fd728b5dacbc64f5eeb1 -r b9804f980783c4a014a66f7cf45979ae290e71f0 templates/webapps/community/repository/common.mako --- a/templates/webapps/community/repository/common.mako +++ b/templates/webapps/community/repository/common.mako @@ -84,7 +84,7 @@ </%def><%def name="render_repository_items( repository_metadata_id, metadata, can_set_metadata=False, webapp='community' )"> - <% from galaxy.webapps.community.controllers.common import encode, decode %> + <% from galaxy.tool_shed.encoding_util import tool_shed_decode %> %if metadata or can_set_metadata: <p/><div class="toolForm"> @@ -236,7 +236,7 @@ %><tr><td> - <a href="${h.url_for( controller='workflow', action='view_workflow', repository_metadata_id=repository_metadata_id, workflow_name=encode( workflow_name ), webapp=webapp )}">${workflow_name}</a> + <a href="${h.url_for( controller='workflow', action='view_workflow', repository_metadata_id=repository_metadata_id, workflow_name=tool_shed_decode( workflow_name ), webapp=webapp )}">${workflow_name}</a></td><td> %if steps: diff -r 98204b9f4f806c15fa52fd728b5dacbc64f5eeb1 -r b9804f980783c4a014a66f7cf45979ae290e71f0 templates/webapps/community/repository/preview_tools_in_changeset.mako --- a/templates/webapps/community/repository/preview_tools_in_changeset.mako +++ b/templates/webapps/community/repository/preview_tools_in_changeset.mako @@ -64,7 +64,7 @@ <br/><br/><ul class="manage-table-actions"> - <li><a class="action-button" href="${h.url_for( controller='repository', action='install_repository_revision', repository_id=trans.security.encode_id( repository.id ), webapp=webapp, changeset_revision=changeset_revision )}">Install to local Galaxy</a></li> + <li><a class="action-button" href="${h.url_for( controller='repository', action='install_repositories_by_revision', repository_ids=trans.security.encode_id( repository.id ), webapp=webapp, changeset_revisions=changeset_revision )}">Install to local Galaxy</a></li><li><a class="action-button" id="repository-${repository.id}-popup" class="menubutton">Tool Shed Actions</a></li><div popupmenu="repository-${repository.id}-popup"><a class="action-button" href="${h.url_for( controller='repository', action='browse_valid_repositories', webapp=webapp )}">Browse valid repositories</a> diff -r 98204b9f4f806c15fa52fd728b5dacbc64f5eeb1 -r b9804f980783c4a014a66f7cf45979ae290e71f0 templates/webapps/community/repository/tool_form.mako --- a/templates/webapps/community/repository/tool_form.mako +++ b/templates/webapps/community/repository/tool_form.mako @@ -123,7 +123,7 @@ %if webapp == 'galaxy': <li><a class="action-button" id="repository-${repository.id}-popup" class="menubutton">Repository Actions</a></li><div popupmenu="repository-${repository.id}-popup"> - <li><a class="action-button" href="${h.url_for( controller='repository', action='install_repository_revision', repository_id=trans.security.encode_id( repository.id ), webapp=webapp, changeset_revision=changeset_revision )}">Install to local Galaxy</a></li> + <li><a class="action-button" href="${h.url_for( controller='repository', action='install_repositories_by_revision', repository_ids=trans.security.encode_id( repository.id ), webapp=webapp, changeset_revisions=changeset_revision )}">Install to local Galaxy</a></li><li><a class="action-button" href="${h.url_for( controller='repository', action='preview_tools_in_changeset', repository_id=trans.security.encode_id( repository.id ), webapp=webapp, changeset_revision=changeset_revision )}">Browse repository</a></li></div><li><a class="action-button" id="tool_shed-${repository.id}-popup" class="menubutton">Tool Shed Actions</a></li> diff -r 98204b9f4f806c15fa52fd728b5dacbc64f5eeb1 -r b9804f980783c4a014a66f7cf45979ae290e71f0 templates/webapps/community/repository/view_repository.mako --- a/templates/webapps/community/repository/view_repository.mako +++ b/templates/webapps/community/repository/view_repository.mako @@ -94,7 +94,7 @@ </div> %endif %else: - <li><a class="action-button" href="${h.url_for( controller='repository', action='install_repository_revision', repository_id=trans.security.encode_id( repository.id ), webapp=webapp, changeset_revision=changeset_revision )}">Install to local Galaxy</a></li> + <li><a class="action-button" href="${h.url_for( controller='repository', action='install_repositories_by_revision', repository_ids=trans.security.encode_id( repository.id ), webapp=webapp, changeset_revisions=changeset_revision )}">Install to local Galaxy</a></li><li><a class="action-button" id="repository-${repository.id}-popup" class="menubutton">Tool Shed Actions</a></li><div popupmenu="repository-${repository.id}-popup"><a class="action-button" href="${h.url_for( controller='repository', action='browse_valid_repositories', webapp=webapp )}">Browse valid repositories</a> diff -r 98204b9f4f806c15fa52fd728b5dacbc64f5eeb1 -r b9804f980783c4a014a66f7cf45979ae290e71f0 templates/webapps/community/repository/view_tool_metadata.mako --- a/templates/webapps/community/repository/view_tool_metadata.mako +++ b/templates/webapps/community/repository/view_tool_metadata.mako @@ -36,7 +36,7 @@ %if webapp == 'galaxy': <li><a class="action-button" id="repository-${repository.id}-popup" class="menubutton">Repository Actions</a></li><div popupmenu="repository-${repository.id}-popup"> - <li><a class="action-button" href="${h.url_for( controller='repository', action='install_repository_revision', repository_id=trans.security.encode_id( repository.id ), webapp=webapp, changeset_revision=changeset_revision )}">Install to local Galaxy</a></li> + <li><a class="action-button" href="${h.url_for( controller='repository', action='install_repositories_by_revision', repository_ids=trans.security.encode_id( repository.id ), webapp=webapp, changeset_revisions=changeset_revision )}">Install to local Galaxy</a></li><li><a class="action-button" href="${h.url_for( controller='repository', action='preview_tools_in_changeset', repository_id=trans.security.encode_id( repository.id ), webapp=webapp, changeset_revision=changeset_revision )}">Browse repository</a></li></div><li><a class="action-button" id="tool_shed-${repository.id}-popup" class="menubutton">Tool Shed Actions</a></li> diff -r 98204b9f4f806c15fa52fd728b5dacbc64f5eeb1 -r b9804f980783c4a014a66f7cf45979ae290e71f0 templates/webapps/community/repository/view_workflow.mako --- a/templates/webapps/community/repository/view_workflow.mako +++ b/templates/webapps/community/repository/view_workflow.mako @@ -5,7 +5,7 @@ <% from galaxy.web.framework.helpers import time_ago - from galaxy.webapps.community.controllers.common import encode + from galaxy.tool_shed.encoding_util import tool_shed_encode in_tool_shed = webapp == 'community' is_admin = trans.user_is_admin() @@ -34,7 +34,7 @@ <%inherit file="${inherit(context)}"/><%def name="render_workflow( repository_metadata_id, workflow_name, webapp )"> - <% center_url = h.url_for( controller='workflow', action='generate_workflow_image', repository_metadata_id=repository_metadata_id, workflow_name=encode( workflow_name ), webapp=webapp ) %> + <% center_url = h.url_for( controller='workflow', action='generate_workflow_image', repository_metadata_id=repository_metadata_id, workflow_name=tool_shed_encode( workflow_name ), webapp=webapp ) %><iframe name="galaxy_main" id="galaxy_main" frameborder="0" style="position: absolute; width: 100%; height: 100%;" src="${center_url}"></iframe></%def> @@ -76,8 +76,8 @@ %else: <li><a class="action-button" id="repository-${repository.id}-popup" class="menubutton">Repository Actions</a></li><div popupmenu="repository-${repository.id}-popup"> - <li><a class="action-button" href="${h.url_for( controller='workflow', action='import_workflow', repository_metadata_id=repository_metadata_id, workflow_name=encode( workflow_name ), webapp=webapp )}">Import workflow to local Galaxy</a></li> - <li><a class="action-button" href="${h.url_for( controller='repository', action='install_repository_revision', repository_id=trans.security.encode_id( repository.id ), webapp=webapp, changeset_revision=changeset_revision )}">Install repository to local Galaxy</a></li> + <li><a class="action-button" href="${h.url_for( controller='workflow', action='import_workflow', repository_metadata_id=repository_metadata_id, workflow_name=tool_shed_encode( workflow_name ), webapp=webapp )}">Import workflow to local Galaxy</a></li> + <li><a class="action-button" href="${h.url_for( controller='repository', action='install_repositories_by_revision', repository_ids=trans.security.encode_id( repository.id ), webapp=webapp, changeset_revisions=changeset_revision )}">Install repository to local Galaxy</a></li></div><li><a class="action-button" id="toolshed-${repository.id}-popup" class="menubutton">Tool Shed Actions</a></li><div popupmenu="toolshed-${repository.id}-popup"> 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.