Beispiel #1
0
 def __init__(self, error):
     HTTPForbidden.__init__(self)
     self.explanation = error_list[error]
Beispiel #2
0
 def install_repository_revision( self, trans, payload, **kwd ):
     """
     POST /api/tool_shed_repositories/install_repository_revision
     Install a specified repository revision from a specified tool shed into Galaxy.
     
     :param key: the current Galaxy admin user's API key
     
     The following parameters are included in the payload.
     :param tool_shed_url (required): the base URL of the Tool Shed from which to install the Repository
     :param name (required): the name of the Repository
     :param owner (required): the owner of the Repository
     :param changset_revision (required): the changset_revision of the RepositoryMetadata object associated with the Repository
     :param new_tool_panel_section_label (optional): label of a new section to be added to the Galaxy tool panel in which to load
                                                     tools contained in the Repository.  Either this parameter must be an empty string or
                                                     the tool_panel_section_id parameter must be an empty string or both must be an empty
                                                     string (both cannot be used simultaneously).
     :param tool_panel_section_id (optional): id of the Galaxy tool panel section in which to load tools contained in the Repository.
                                              If this parameter is an empty string and the above new_tool_panel_section_label parameter is an
                                              empty string, tools will be loaded outside of any sections in the tool panel.  Either this
                                              parameter must be an empty string or the tool_panel_section_id parameter must be an empty string
                                              of both must be an empty string (both cannot be used simultaneously).
     :param install_repository_dependencies (optional): Set to True if you want to install repository dependencies defined for the specified
                                                        repository being installed.  The default setting is False.
     :param install_tool_dependencies (optional): Set to True if you want to install tool dependencies defined for the specified repository being
                                                  installed.  The default setting is False.
     :param shed_tool_conf (optional): The shed-related tool panel configuration file configured in the "tool_config_file" setting in the Galaxy config file
                                       (e.g., universe_wsgi.ini).  At least one shed-related tool panel config file is required to be configured. Setting
                                       this parameter to a specific file enables you to choose where the specified repository will be installed because
                                       the tool_path attribute of the <toolbox> from the specified file is used as the installation location
                                       (e.g., <toolbox tool_path="../shed_tools">).  If this parameter is not set, a shed-related tool panel configuration
                                       file will be selected automatically.
     """
     # Get the information about the repository to be installed from the payload.
     tool_shed_url = payload.get( 'tool_shed_url', '' )
     if not tool_shed_url:
         raise HTTPBadRequest( detail="Missing required parameter 'tool_shed_url'." )
     name = payload.get( 'name', '' )
     if not name:
         raise HTTPBadRequest( detail="Missing required parameter 'name'." )
     owner = payload.get( 'owner', '' )
     if not owner:
         raise HTTPBadRequest( detail="Missing required parameter 'owner'." )
     changeset_revision = payload.get( 'changeset_revision', '' )
     if not changeset_revision:
         raise HTTPBadRequest( detail="Missing required parameter 'changeset_revision'." )
     # Make sure this Galaxy instance is configured with a shed-related tool panel configuration file.
     if not suc.have_shed_tool_conf_for_install( trans ):
         message = get_message_for_no_shed_tool_config()
         log.error( message, exc_info=True )
         trans.response.status = 500
         return dict( status='error', error=message )
     # Make sure the current user's API key proves he is an admin user in this Galaxy instance.
     if not trans.user_is_admin():
         raise HTTPForbidden( detail='You are not authorized to install a tool shed repository into this Galaxy instance.' )
     # Keep track of all repositories that are installed - there may be more than one if repository dependencies are installed.
     installed_tool_shed_repositories = []
     # Get all of the information necessary for installing the repository from the specified tool shed.
     url = suc.url_join( tool_shed_url,
                         'api/repositories/get_repository_revision_install_info?name=%s&owner=%s&changeset_revision=%s' % \
                         ( name, owner, changeset_revision ) )
     try:
         raw_text = common_util.tool_shed_get( trans.app, tool_shed_url, url )
     except Exception, e:
         message = "Error attempting to retrieve installation information from tool shed %s for revision %s of repository %s owned by %s: %s" % \
             ( str( tool_shed_url ), str( changeset_revision ), str( name ), str( owner ), str( e ) )
         log.error( message, exc_info=True )
         trans.response.status = 500
         return dict( status='error', error=message )
Beispiel #3
0
 def __init__(self, error):
     HTTPForbidden.__init__(self)
     self.explanation = error_list[error]
Beispiel #4
0
 def install_repository_revisions( self, trans, payload, **kwd ):
     """
     POST /api/tool_shed_repositories/install_repository_revisions
     Install one or more specified repository revisions from one or more specified tool sheds into Galaxy.  The received parameters
     must be ordered lists so that positional values in tool_shed_urls, names, owners and changeset_revisions are associated.
     
     It's questionable whether this method is needed as the above method for installing a single repository can probably cover all
     desired scenarios.  We'll keep this one around just in case...
     
     :param key: the current Galaxy admin user's API key
     
     The following parameters are included in the payload.
     :param tool_shed_urls: the base URLs of the Tool Sheds from which to install a specified Repository
     :param names: the names of the Repositories to be installed
     :param owners: the owners of the Repositories to be installed
     :param changset_revisions: the changset_revisions of each RepositoryMetadata object associated with each Repository to be installed
     :param new_tool_panel_section_label: optional label of a new section to be added to the Galaxy tool panel in which to load
                                          tools contained in the Repository.  Either this parameter must be an empty string or
                                          the tool_panel_section_id parameter must be an empty string, as both cannot be used.
     :param tool_panel_section_id: optional id of the Galaxy tool panel section in which to load tools contained in the Repository.
                                   If not set, tools will be loaded outside of any sections in the tool panel.  Either this
                                   parameter must be an empty string or the tool_panel_section_id parameter must be an empty string,
                                   as both cannot be used.
     :param install_repository_dependencies (optional): Set to True if you want to install repository dependencies defined for the specified
                                                        repository being installed.  The default setting is False.
     :param install_tool_dependencies (optional): Set to True if you want to install tool dependencies defined for the specified repository being
                                                  installed.  The default setting is False.
     :param shed_tool_conf (optional): The shed-related tool panel configuration file configured in the "tool_config_file" setting in the Galaxy config file
                                       (e.g., universe_wsgi.ini).  At least one shed-related tool panel config file is required to be configured. Setting
                                       this parameter to a specific file enables you to choose where the specified repository will be installed because
                                       the tool_path attribute of the <toolbox> from the specified file is used as the installation location
                                       (e.g., <toolbox tool_path="../shed_tools">).  If this parameter is not set, a shed-related tool panel configuration
                                       file will be selected automatically.
     """
     if not suc.have_shed_tool_conf_for_install( trans ):
         # This Galaxy instance is not configured with a shed-related tool panel configuration file.
         message = get_message_for_no_shed_tool_config()
         log.error( message, exc_info=True )
         trans.response.status = 500
         return dict( status='error', error=message )
     if not trans.user_is_admin():
         raise HTTPForbidden( detail='You are not authorized to install a tool shed repository into this Galaxy instance.' )
     # Get the information about all of the repositories to be installed.
     tool_shed_urls = util.listify( payload.get( 'tool_shed_urls', '' ) )
     names = util.listify( payload.get( 'names', '' ) )
     owners = util.listify( payload.get( 'owners', '' ) )
     changeset_revisions = util.listify( payload.get( 'changeset_revisions', '' ) )
     num_specified_repositories = len( tool_shed_urls )
     if len( names ) != num_specified_repositories or \
         len( owners ) != num_specified_repositories or \
         len( changeset_revisions ) != num_specified_repositories:
         message = 'Error in tool_shed_repositories API in install_repository_revisions: the received parameters must be ordered '
         message += 'lists so that positional values in tool_shed_urls, names, owners and changeset_revisions are associated.'
         log.error( message, exc_info=True )
         trans.response.status = 500
         return dict( status='error', error=message )
     # Get the information about the Galaxy components (e.g., tool pane section, tool config file, etc) that will contain information
     # about each of the repositories being installed.
     # TODO: we may want to enhance this method to allow for each of the following to be associated with each repository instead of
     # forcing all repositories to use the same settings.
     install_repository_dependencies = payload.get( 'install_repository_dependencies', False )
     install_tool_dependencies = payload.get( 'install_tool_dependencies', False )
     new_tool_panel_section_label = payload.get( 'new_tool_panel_section_label', '' )
     shed_tool_conf = payload.get( 'shed_tool_conf', None )
     tool_path = payload.get( 'tool_path', None )
     tool_panel_section_id = payload.get( 'tool_panel_section_id', '' )
     all_installed_tool_shed_repositories = []
     for index, tool_shed_url in enumerate( tool_shed_urls ):
         current_payload = {}
         current_payload[ 'tool_shed_url' ] = tool_shed_url
         current_payload[ 'name' ] = names[ index ]
         current_payload[ 'owner' ] = owners[ index ]
         current_payload[ 'changeset_revision' ] = changeset_revisions[ index ]
         current_payload[ 'new_tool_panel_section_label' ] = new_tool_panel_section_label
         current_payload[ 'tool_panel_section_id' ] = tool_panel_section_id
         current_payload[ 'install_repository_dependencies' ] = install_repository_dependencies
         current_payload[ 'install_tool_dependencies' ] = install_tool_dependencies
         current_payload[ 'shed_tool_conf' ] = shed_tool_conf
         installed_tool_shed_repositories = self.install_repository_revision( trans, **current_payload )
         if isinstance( installed_tool_shed_repositories, dict ):
             # We encountered an error.
             return installed_tool_shed_repositories
         elif isinstance( installed_tool_shed_repositories, list ):
             all_installed_tool_shed_repositories.extend( installed_tool_shed_repositories )
     return all_installed_tool_shed_repositories