1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/b62855bbd52e/ changeset: b62855bbd52e user: greg date: 2011-11-10 16:57:39 summary: Add the ability to enter a new tool panel section label when installing repositories with tools from a tool shed in addition to being able to choose an existing tool panel section for containing the tools. Also clean up code related to message displayed when a local Galaxy instance is missing tools required by an imported workflow. affected #: 5 files diff -r 23198e766859394108d48de1489be7052530d38b -r b62855bbd52e68b7ecac586e3bc329c7e472bc47 lib/galaxy/web/base/controller.py --- a/lib/galaxy/web/base/controller.py +++ b/lib/galaxy/web/base/controller.py @@ -22,6 +22,7 @@ pkg_resources.require( 'elementtree' ) from elementtree import ElementTree, ElementInclude +from elementtree.ElementTree import Element log = logging.getLogger( __name__ ) diff -r 23198e766859394108d48de1489be7052530d38b -r b62855bbd52e68b7ecac586e3bc329c7e472bc47 lib/galaxy/web/controllers/admin.py --- a/lib/galaxy/web/controllers/admin.py +++ b/lib/galaxy/web/controllers/admin.py @@ -3,7 +3,7 @@ from galaxy.model.orm import * from galaxy.web.framework.helpers import time_ago, iff, grids from galaxy.tools.search import ToolBoxSearch -from galaxy.tools import json_fix +from galaxy.tools import ToolSection, json_fix import logging log = logging.getLogger( __name__ ) @@ -403,7 +403,7 @@ def get_value( self, trans, grid, tool_shed_repository ): return tool_shed_repository.tool_shed # Grid definition - title = "Tool shed repositories" + title = "Installed tool shed repositories" model_class = model.ToolShedRepository template='/admin/tool_shed_repository/grid.mako' default_sort_key = "name" @@ -807,28 +807,45 @@ status = kwd.get( 'status', 'done' ) tool_shed_url = kwd[ 'tool_shed_url' ] repo_info_dict = kwd[ 'repo_info_dict' ] + new_tool_panel_section = kwd.get( 'new_tool_panel_section', '' ) + tool_panel_section = kwd.get( 'tool_panel_section', '' ) if kwd.get( 'select_tool_panel_section_button', False ): shed_tool_conf = kwd[ 'shed_tool_conf' ] # Get the tool path. for k, tool_path in trans.app.toolbox.shed_tool_confs.items(): if k == shed_tool_conf: break - if 'tool_panel_section' in kwd: - section_key = 'section_%s' % kwd[ 'tool_panel_section' ] - tool_section = trans.app.toolbox.tool_panel[ section_key ] + if new_tool_panel_section or tool_panel_section: + if new_tool_panel_section: + section_id = new_tool_panel_section.lower().replace( ' ', '_' ) + new_section_key = 'section_%s' % str( section_id ) + if new_section_key in trans.app.toolbox.tool_panel: + # Appending a tool to an existing section in trans.app.toolbox.tool_panel + log.debug( "Appending to tool panel section: %s" % new_tool_panel_section ) + tool_section = trans.app.toolbox.tool_panel[ new_section_key ] + else: + # Appending a new section to trans.app.toolbox.tool_panel + log.debug( "Loading new tool panel section: %s" % new_tool_panel_section ) + elem = Element( 'section' ) + elem.attrib[ 'name' ] = new_tool_panel_section + elem.attrib[ 'id' ] = section_id + tool_section = ToolSection( elem ) + trans.app.toolbox.tool_panel[ new_section_key ] = tool_section + else: + section_key = 'section_%s' % tool_panel_section + tool_section = trans.app.toolbox.tool_panel[ section_key ] # Decode the encoded repo_info_dict param value. repo_info_dict = tool_shed_decode( repo_info_dict ) # Clone the repository to the configured location. current_working_dir = os.getcwd() + installed_repository_names = [] for name, repo_info_tuple in repo_info_dict.items(): description, repository_clone_url, changeset_revision = repo_info_tuple clone_dir = os.path.join( tool_path, self.__generate_tool_path( repository_clone_url, changeset_revision ) ) if os.path.exists( clone_dir ): # Repository and revision has already been cloned. # TODO: implement the ability to re-install or revert an existing repository. - message += 'Revision <b>%s</b> of repository <b>%s</b> has already been installed. Updating an existing repository is not yet supported.<br/>' % \ - ( changeset_revision, name ) - status = 'error' + message += 'Revision <b>%s</b> of repository <b>%s</b> was previously installed.<br/>' % ( changeset_revision, name ) else: os.makedirs( clone_dir ) log.debug( 'Cloning %s...' % repository_clone_url ) @@ -892,9 +909,7 @@ if trans.app.toolbox_search.enabled: # If search support for tools is enabled, index the new installed tools. trans.app.toolbox_search = ToolBoxSearch( trans.app.toolbox ) - message += 'Revision <b>%s</b> of repository <b>%s</b> has been loaded into tool panel section <b>%s</b>.<br/>' % \ - ( changeset_revision, name, tool_section.name ) - #return trans.show_ok_message( message ) + installed_repository_names.append( name ) else: tmp_stderr = open( tmp_name, 'rb' ) message += '%s<br/>' % tmp_stderr.read() @@ -905,6 +920,19 @@ message += '%s<br/>' % tmp_stderr.read() tmp_stderr.close() status = 'error' + if installed_repository_names: + installed_repository_names.sort() + message += 'These %d repositories were installed and all tools were loaded into tool panel section <b>%s</b>:<br/>' % \ + ( len( installed_repository_names ), tool_section.name ) + for i, repo_name in enumerate( installed_repository_names ): + if i == len( installed_repository_names ) -1: + message += '%s.<br/>' % repo_name + else: + message += '%s, ' % repo_name + return trans.response.send_redirect( web.url_for( controller='admin', + action='browse_tool_shed_repositories', + message=message, + status=status ) ) else: message = 'Choose the section in your tool panel to contain the installed tools.' status = 'error' @@ -921,6 +949,7 @@ shed_tool_conf=shed_tool_conf, shed_tool_conf_select_field=shed_tool_conf_select_field, tool_panel_section_select_field=tool_panel_section_select_field, + new_tool_panel_section=new_tool_panel_section, message=message, status=status ) @web.expose diff -r 23198e766859394108d48de1489be7052530d38b -r b62855bbd52e68b7ecac586e3bc329c7e472bc47 lib/galaxy/web/controllers/workflow.py --- a/lib/galaxy/web/controllers/workflow.py +++ b/lib/galaxy/web/controllers/workflow.py @@ -1115,10 +1115,10 @@ workflow_name = tool_shed_decode( workflow_name ) # The following parameters will have a value only if the import originated # from a tool shed repository installed locally. - local_file = kwd.get( 'local_file', '' ) + installed_repository_file = kwd.get( 'installed_repository_file', '' ) repository_id = kwd.get( 'repository_id', '' ) - if local_file and not import_button: - workflow_file = open( local_file, 'rb' ) + if installed_repository_file and not import_button: + workflow_file = open( installed_repository_file, 'rb' ) workflow_text = workflow_file.read() workflow_file.close() import_button = True @@ -1197,27 +1197,26 @@ if shed_url.endswith( '/' ): shed_url = shed_url.rstrip( '/' ) url = '%s/repository/find_tools?galaxy_url=%s&webapp=%s' % ( shed_url, trans.request.host, webapp ) + if missing_tool_tups: + url += '&tool_id=' for missing_tool_tup in missing_tool_tups: missing_tool_id = missing_tool_tup[0] - url += '&tool_id=%s' % missing_tool_id + url += '%s,' % missing_tool_id message += '<a href="%s">%s</a><br/>' % ( url, shed_name ) status = 'error' - if local_file or tool_shed_url: + if installed_repository_file or tool_shed_url: # Another Galaxy panels Hack: The request did not originate from the Galaxy # workflow view, so we don't need to render the Galaxy panels. - return trans.response.send_redirect( web.url_for( controller='admin', - action='center', - webapp='galaxy', - message=message, - status=status ) ) + action = 'center' else: # Another Galaxy panels hack: The request originated from the Galaxy # workflow view, so we need to render the Galaxy panels. - return trans.response.send_redirect( web.url_for( controller='admin', - action='index', - webapp='galaxy', - message=message, - status=status ) ) + action = 'index' + return trans.response.send_redirect( web.url_for( controller='admin', + action=action, + webapp='galaxy', + message=message, + status=status ) ) else: # TODO: Figure out what to do here... pass @@ -1228,7 +1227,7 @@ url = 'http://%s/workflow/view_workflow?repository_metadata_id=%s&workflow_name=%s&webapp=%s&message=%s' % \ ( tool_shed_url, repository_metadata_id, tool_shed_encode( workflow_name ), webapp, message ) return trans.response.send_redirect( url ) - elif local_file: + elif installed_repository_file: # The workflow was read from a file included with an installed tool shed repository. message = "Workflow <b>%s</b> imported successfully." % workflow.name return trans.response.send_redirect( web.url_for( controller='admin', diff -r 23198e766859394108d48de1489be7052530d38b -r b62855bbd52e68b7ecac586e3bc329c7e472bc47 templates/admin/select_tool_panel_section.mako --- a/templates/admin/select_tool_panel_section.mako +++ b/templates/admin/select_tool_panel_section.mako @@ -23,7 +23,7 @@ <br/><div class="toolForm"> - <div class="toolFormTitle">Load tools into tool panel</div> + <div class="toolFormTitle">Choose section to load tools into tool panel</div><div class="toolFormBody"><form name="select_tool_panel_section" id="select_tool_panel_section" action="${h.url_for( controller='admin', action='install_tool_shed_repository', tool_shed_url=tool_shed_url, repo_info_dict=repo_info_dict )}" method="post" > %if shed_tool_conf_select_field: @@ -40,10 +40,17 @@ <input type="hidden" name="shed_tool_conf" value="${shed_tool_conf}"/> %endif <div class="form-row"> - <label>Tool panel section:</label> + <label>Add new tool panel section:</label> + <input name="new_tool_panel_section" type="textfield" value="${new_tool_panel_section}" size="40"/> + <div class="toolParamHelp" style="clear: both;"> + Add a new tool panel section or choose an existing section in your tool panel below to contain the installed tools. + </div> + </div> + <div class="form-row"> + <label>Select existing tool panel section:</label> ${tool_panel_section_select_field.get_html()} <div class="toolParamHelp" style="clear: both;"> - Choose the section in your tool panel to contain the installed tools. + Choose an existing section in your tool panel to contain the installed tools. </div></div><div class="form-row"> diff -r 23198e766859394108d48de1489be7052530d38b -r b62855bbd52e68b7ecac586e3bc329c7e472bc47 templates/admin/tool_shed_repository/browse_repository.mako --- a/templates/admin/tool_shed_repository/browse_repository.mako +++ b/templates/admin/tool_shed_repository/browse_repository.mako @@ -103,7 +103,7 @@ <div class="menubutton" style="float: left;" id="workflow-${index}-popup"> ${workflow_name} <div popupmenu="workflow-${index}-popup"> - <a class="action-button" href="${h.url_for( controller='workflow', action='import_workflow', local_file=full_path, repository_id=trans.security.encode_id( repository.id ) )}">Import to Galaxy</a> + <a class="action-button" href="${h.url_for( controller='workflow', action='import_workflow', installed_repository_file=full_path, repository_id=trans.security.encode_id( repository.id ) )}">Import to Galaxy</a></div></div></td> 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.