diff --git a/lib/galaxy/web/base/controller.py b/lib/galaxy/web/base/controller.py index b4cbec7a497..2cb1db6ce55 100644 --- a/lib/galaxy/web/base/controller.py +++ b/lib/galaxy/web/base/controller.py @@ -22,6 +22,7 @@ from Cheetah.Template import Template pkg_resources.require( 'elementtree' ) from elementtree import ElementTree, ElementInclude +from elementtree.ElementTree import Element log = logging.getLogger( __name__ ) diff --git a/lib/galaxy/web/controllers/admin.py b/lib/galaxy/web/controllers/admin.py index 2080571fda0..bde9352111b 100644 --- a/lib/galaxy/web/controllers/admin.py +++ b/lib/galaxy/web/controllers/admin.py @@ -3,7 +3,7 @@ from galaxy import model 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 @@ class RepositoryListGrid( grids.Grid ): 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 @@ class AdminGalaxy( BaseUIController, Admin, AdminActions, UsesQuota, QuotaParamP 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 %s of repository %s has already been installed. Updating an existing repository is not yet supported.
' % \ - ( changeset_revision, name ) - status = 'error' + message += 'Revision %s of repository %s was previously installed.
' % ( changeset_revision, name ) else: os.makedirs( clone_dir ) log.debug( 'Cloning %s...' % repository_clone_url ) @@ -892,9 +909,7 @@ class AdminGalaxy( BaseUIController, Admin, AdminActions, UsesQuota, QuotaParamP 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 %s of repository %s has been loaded into tool panel section %s.
' % \ - ( 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
' % tmp_stderr.read() @@ -905,6 +920,19 @@ class AdminGalaxy( BaseUIController, Admin, AdminActions, UsesQuota, QuotaParamP message += '%s
' % 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 %s:
' % \ + ( 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.
' % 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 @@ class AdminGalaxy( BaseUIController, Admin, AdminActions, UsesQuota, QuotaParamP 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 --git a/lib/galaxy/web/controllers/workflow.py b/lib/galaxy/web/controllers/workflow.py index 700ecdf7d47..f15d8a6b1f4 100644 --- a/lib/galaxy/web/controllers/workflow.py +++ b/lib/galaxy/web/controllers/workflow.py @@ -1115,10 +1115,10 @@ class WorkflowController( BaseUIController, Sharable, UsesStoredWorkflow, UsesAn 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 @@ class WorkflowController( BaseUIController, Sharable, UsesStoredWorkflow, UsesAn 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 += '%s
' % ( 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 @@ class WorkflowController( BaseUIController, Sharable, UsesStoredWorkflow, UsesAn 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 %s imported successfully." % workflow.name return trans.response.send_redirect( web.url_for( controller='admin', diff --git a/templates/admin/select_tool_panel_section.mako b/templates/admin/select_tool_panel_section.mako index 045c418143a..1a0b90058db 100644 --- a/templates/admin/select_tool_panel_section.mako +++ b/templates/admin/select_tool_panel_section.mako @@ -23,7 +23,7 @@
-
Load tools into tool panel
+
Choose section to load tools into tool panel
%if shed_tool_conf_select_field: @@ -40,10 +40,17 @@ %endif
- + + +
+ Add a new tool panel section or choose an existing section in your tool panel below to contain the installed tools. +
+
+
+ ${tool_panel_section_select_field.get_html()}
- 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.
diff --git a/templates/admin/tool_shed_repository/browse_repository.mako b/templates/admin/tool_shed_repository/browse_repository.mako index b8d9ea5a7a7..10f3a95a8b3 100644 --- a/templates/admin/tool_shed_repository/browse_repository.mako +++ b/templates/admin/tool_shed_repository/browse_repository.mako @@ -103,7 +103,7 @@