def get_installed_repositories_from_repository_dependencies( self, repository_dependencies_dict ): installed_repositories = [] if repository_dependencies_dict and isinstance( repository_dependencies_dict, dict ): for rd_key, rd_vals in repository_dependencies_dict.items(): if rd_key in [ 'root_key', 'description' ]: continue # rd_key is something like: 'http://localhost:9009__ESEP__package_rdkit_2012_12__ESEP__test__ESEP__d635ffb9c665__ESEP__True' # rd_val is something like: [['http://localhost:9009', 'package_numpy_1_7', 'test', 'cddd64ecd985', 'True']] repository_components_tuple = container_util.get_components_from_key( rd_key ) components_list = suc.extract_components_from_tuple( repository_components_tuple ) tool_shed, name, owner, changeset_revision = components_list[ 0:4 ] installed_repository = suc.get_installed_repository( self.app, tool_shed=tool_shed, name=name, owner=owner, changeset_revision=changeset_revision ) if ( installed_repository ) and ( installed_repository not in installed_repositories ): installed_repositories.append( installed_repository ) for rd_val in rd_vals: tool_shed, name, owner, changeset_revision = rd_val[ 0:4 ] installed_repository = suc.get_installed_repository( self.app, tool_shed=tool_shed, name=name, owner=owner, changeset_revision=changeset_revision ) if ( installed_repository ) and ( installed_repository not in installed_repositories ): installed_repositories.append( installed_repository ) return installed_repositories
def repair_repository_revision(self, trans, payload, **kwd): """ POST /api/tool_shed_repositories/repair_repository_revision Repair a specified repository revision previously installed 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 the Repository was installed :param name (required): the name of the Repository :param owner (required): the owner of the Repository :param changeset_revision (required): the changeset_revision of the RepositoryMetadata object associated with the Repository """ # Get the information about the repository to be installed from the payload. tool_shed_url, name, owner, changeset_revision = self.__parse_repository_from_payload( payload, include_changeset=True) tool_shed_repositories = [] tool_shed_repository = suc.get_installed_repository( trans.app, tool_shed=tool_shed_url, name=name, owner=owner, changeset_revision=changeset_revision) rrm = RepairRepositoryManager(trans.app) repair_dict = rrm.get_repair_dict(tool_shed_repository) ordered_tsr_ids = repair_dict.get('ordered_tsr_ids', []) ordered_repo_info_dicts = repair_dict.get('ordered_repo_info_dicts', []) if ordered_tsr_ids and ordered_repo_info_dicts: for index, tsr_id in enumerate(ordered_tsr_ids): repository = trans.install_model.context.query( trans.install_model.ToolShedRepository).get( trans.security.decode_id(tsr_id)) repo_info_dict = ordered_repo_info_dicts[index] # TODO: handle errors in repair_dict. repair_dict = rrm.repair_tool_shed_repository( repository, encoding_util.tool_shed_encode(repo_info_dict)) repository_dict = repository.to_dict( value_mapper=self.__get_value_mapper(trans, repository)) repository_dict['url'] = web.url_for( controller='tool_shed_repositories', action='show', id=trans.security.encode_id(repository.id)) if repair_dict: errors = repair_dict.get(repository.name, []) repository_dict['errors_attempting_repair'] = ' '.join( errors) tool_shed_repositories.append(repository_dict) # Display the list of repaired repositories. return tool_shed_repositories
def load_from_element( self, elem, tool_path ): assert elem.tag == 'data_manager', 'A data manager configuration must have a "data_manager" tag as the root. "%s" is present' % ( elem.tag ) self.declared_id = elem.get( 'id', None ) self.guid = elem.get( 'guid', None ) path = elem.get( 'tool_file', None ) self.version = elem.get( 'version', self.version ) tool_shed_repository_id = None tool_guid = None if path is None: tool_elem = elem.find( 'tool' ) assert tool_elem is not None, "Error loading tool for data manager. Make sure that a tool_file attribute or a tool tag set has been defined:\n%s" % ( util.xml_to_string( elem ) ) path = tool_elem.get( "file", None ) tool_guid = tool_elem.get( "guid", None ) # need to determine repository info so that dependencies will work correctly tool_shed_url = tool_elem.find( 'tool_shed' ).text # Handle protocol changes. tool_shed_url = common_util.get_tool_shed_url_from_tool_shed_registry( self.data_managers.app, tool_shed_url ) # The protocol is not stored in the database. tool_shed = common_util.remove_protocol_from_tool_shed_url( tool_shed_url ) repository_name = tool_elem.find( 'repository_name' ).text repository_owner = tool_elem.find( 'repository_owner' ).text installed_changeset_revision = tool_elem.find( 'installed_changeset_revision' ).text self.tool_shed_repository_info_dict = dict( tool_shed=tool_shed, name=repository_name, owner=repository_owner, installed_changeset_revision=installed_changeset_revision ) tool_shed_repository = \ suc.get_installed_repository( self.data_managers.app, tool_shed=tool_shed, name=repository_name, owner=repository_owner, installed_changeset_revision=installed_changeset_revision ) if tool_shed_repository is None: log.warning( 'Could not determine tool shed repository from database. This should only ever happen when running tests.' ) # we'll set tool_path manually here from shed_conf_file tool_shed_repository_id = None try: tool_path = util.parse_xml( elem.get( 'shed_conf_file' ) ).getroot().get( 'tool_path', tool_path ) except Exception, e: log.error( 'Error determining tool_path for Data Manager during testing: %s', e ) else: tool_shed_repository_id = self.data_managers.app.security.encode_id( tool_shed_repository.id ) # use shed_conf_file to determine tool_path shed_conf_file = elem.get( "shed_conf_file", None ) if shed_conf_file: shed_conf = self.data_managers.app.toolbox.get_shed_config_dict_by_filename( shed_conf_file, None ) if shed_conf: tool_path = shed_conf.get( "tool_path", tool_path )
def repair_repository_revision( self, trans, payload, **kwd ): """ POST /api/tool_shed_repositories/repair_repository_revision Repair a specified repository revision previously installed 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 the Repository was installed :param name (required): the name of the Repository :param owner (required): the owner of the Repository :param changeset_revision (required): the changeset_revision of the RepositoryMetadata object associated with the Repository """ # Get the information about the repository to be installed from the payload. tool_shed_url, name, owner, changeset_revision = self.__parse_repository_from_payload( payload, include_changeset=True ) tool_shed_repositories = [] tool_shed_repository = suc.get_installed_repository( trans.app, tool_shed=tool_shed_url, name=name, owner=owner, changeset_revision=changeset_revision ) rrm = RepairRepositoryManager( trans.app ) repair_dict = rrm.get_repair_dict( tool_shed_repository ) ordered_tsr_ids = repair_dict.get( 'ordered_tsr_ids', [] ) ordered_repo_info_dicts = repair_dict.get( 'ordered_repo_info_dicts', [] ) if ordered_tsr_ids and ordered_repo_info_dicts: for index, tsr_id in enumerate( ordered_tsr_ids ): repository = trans.install_model.context.query( trans.install_model.ToolShedRepository ).get( trans.security.decode_id( tsr_id ) ) repo_info_dict = ordered_repo_info_dicts[ index ] # TODO: handle errors in repair_dict. repair_dict = rrm.repair_tool_shed_repository( repository, encoding_util.tool_shed_encode( repo_info_dict ) ) repository_dict = repository.to_dict( value_mapper=self.__get_value_mapper( trans, repository ) ) repository_dict[ 'url' ] = web.url_for( controller='tool_shed_repositories', action='show', id=trans.security.encode_id( repository.id ) ) if repair_dict: errors = repair_dict.get( repository.name, [] ) repository_dict[ 'errors_attempting_repair' ] = ' '.join( errors ) tool_shed_repositories.append( repository_dict ) # Display the list of repaired repositories. return tool_shed_repositories
def load_from_element(self, elem, tool_path): assert elem.tag == 'data_manager', 'A data manager configuration must have a "data_manager" tag as the root. "%s" is present' % ( elem.tag) self.declared_id = elem.get('id', None) self.guid = elem.get('guid', None) path = elem.get('tool_file', None) self.version = elem.get('version', self.version) tool_shed_repository_id = None tool_guid = None if path is None: tool_elem = elem.find('tool') assert tool_elem is not None, "Error loading tool for data manager. Make sure that a tool_file attribute or a tool tag set has been defined:\n%s" % ( util.xml_to_string(elem)) path = tool_elem.get("file", None) tool_guid = tool_elem.get("guid", None) # need to determine repository info so that dependencies will work correctly tool_shed_url = tool_elem.find('tool_shed').text # Handle protocol changes. tool_shed_url = common_util.get_tool_shed_url_from_tool_shed_registry( self.data_managers.app, tool_shed_url) # The protocol is not stored in the database. tool_shed = common_util.remove_protocol_from_tool_shed_url( tool_shed_url) repository_name = tool_elem.find('repository_name').text repository_owner = tool_elem.find('repository_owner').text installed_changeset_revision = tool_elem.find( 'installed_changeset_revision').text self.tool_shed_repository_info_dict = dict( tool_shed=tool_shed, name=repository_name, owner=repository_owner, installed_changeset_revision=installed_changeset_revision) tool_shed_repository = \ suc.get_installed_repository( self.data_managers.app, tool_shed=tool_shed, name=repository_name, owner=repository_owner, installed_changeset_revision=installed_changeset_revision ) if tool_shed_repository is None: log.warning( 'Could not determine tool shed repository from database. This should only ever happen when running tests.' ) # we'll set tool_path manually here from shed_conf_file tool_shed_repository_id = None try: tool_path = util.parse_xml( elem.get('shed_conf_file')).getroot().get( 'tool_path', tool_path) except Exception, e: log.error( 'Error determining tool_path for Data Manager during testing: %s', e) else: tool_shed_repository_id = self.data_managers.app.security.encode_id( tool_shed_repository.id) # use shed_conf_file to determine tool_path shed_conf_file = elem.get("shed_conf_file", None) if shed_conf_file: shed_conf = self.data_managers.app.toolbox.get_shed_config_dict_by_filename( shed_conf_file, None) if shed_conf: tool_path = shed_conf.get("tool_path", tool_path)