当前位置: 首页>>代码示例>>Python>>正文


Python xml_util.parse_xml函数代码示例

本文整理汇总了Python中tool_shed.util.xml_util.parse_xml函数的典型用法代码示例。如果您正苦于以下问题:Python parse_xml函数的具体用法?Python parse_xml怎么用?Python parse_xml使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了parse_xml函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: check_for_missing_tools

def check_for_missing_tools( app, tool_panel_configs, latest_tool_migration_script_number ):
    # Get the 000x_tools.xml file associated with the current migrate_tools version number.
    tools_xml_file_path = os.path.abspath( os.path.join( 'scripts', 'migrate_tools', '%04d_tools.xml' % latest_tool_migration_script_number ) )
    # Parse the XML and load the file attributes for later checking against the proprietary tool_panel_config.
    migrated_tool_configs_dict = odict()
    tree, error_message = xml_util.parse_xml( tools_xml_file_path )
    if tree is None:
        return False, odict()
    root = tree.getroot()
    tool_shed = root.get( 'name' )
    tool_shed_url = get_tool_shed_url_from_tools_xml_file_path( app, tool_shed )
    # The default behavior is that the tool shed is down.
    tool_shed_accessible = False
    missing_tool_configs_dict = odict()
    if tool_shed_url:
        for elem in root:
            if elem.tag == 'repository':
                tool_dependencies = []
                tool_dependencies_dict = {}
                repository_name = elem.get( 'name' )
                changeset_revision = elem.get( 'changeset_revision' )
                url = '%s/repository/get_tool_dependencies?name=%s&owner=%s&changeset_revision=%s&from_install_manager=True' % \
                ( tool_shed_url, repository_name, REPOSITORY_OWNER, changeset_revision )
                try:
                    text = tool_shed_get( app, tool_shed_url, url )
                    tool_shed_accessible = True
                except Exception, e:
                    # Tool shed may be unavailable - we have to set tool_shed_accessible since we're looping.
                    tool_shed_accessible = False
                    print "The URL\n%s\nraised the exception:\n%s\n" % ( url, str( e ) )
                if tool_shed_accessible:
                    if text:
                        tool_dependencies_dict = encoding_util.tool_shed_decode( text )
                        for dependency_key, requirements_dict in tool_dependencies_dict.items():
                            tool_dependency_name = requirements_dict[ 'name' ]
                            tool_dependency_version = requirements_dict[ 'version' ]
                            tool_dependency_type = requirements_dict[ 'type' ]
                            tool_dependency_readme = requirements_dict.get( 'readme', '' )
                            tool_dependencies.append( ( tool_dependency_name, tool_dependency_version, tool_dependency_type, tool_dependency_readme ) )
                    for tool_elem in elem.findall( 'tool' ):
                        migrated_tool_configs_dict[ tool_elem.get( 'file' ) ] = tool_dependencies
        if tool_shed_accessible:
            # Parse the proprietary tool_panel_configs (the default is tool_conf.xml) and generate the list of missing tool config file names.
            for tool_panel_config in tool_panel_configs:
                tree, error_message = xml_util.parse_xml( tool_panel_config )
                if tree:
                    root = tree.getroot()
                    for elem in root:
                        if elem.tag == 'tool':
                            missing_tool_configs_dict = check_tool_tag_set( elem, migrated_tool_configs_dict, missing_tool_configs_dict )
                        elif elem.tag == 'section':
                            for section_elem in elem:
                                if section_elem.tag == 'tool':
                                    missing_tool_configs_dict = check_tool_tag_set( section_elem, migrated_tool_configs_dict, missing_tool_configs_dict )
开发者ID:knowingchaos,项目名称:galaxy,代码行数:54,代码来源:common_util.py

示例2: load_tool_from_tmp_config

 def load_tool_from_tmp_config( self, repo, repository_id, ctx, ctx_file, work_dir ):
     tool = None
     message = ''
     tmp_tool_config = hg_util.get_named_tmpfile_from_ctx( ctx, ctx_file, work_dir )
     if tmp_tool_config:
         tool_element, error_message = xml_util.parse_xml( tmp_tool_config )
         if tool_element is None:
             return tool, message
         # Look for external files required by the tool config.
         tmp_code_files = []
         external_paths = Tool.get_externally_referenced_paths( tmp_tool_config )
         for path in external_paths:
             tmp_code_file_name = hg_util.copy_file_from_manifest( repo, ctx, path, work_dir )
             if tmp_code_file_name:
                 tmp_code_files.append( tmp_code_file_name )
         tool, valid, message = self.load_tool_from_config( repository_id, tmp_tool_config )
         for tmp_code_file in tmp_code_files:
             try:
                 os.unlink( tmp_code_file )
             except:
                 pass
         try:
             os.unlink( tmp_tool_config )
         except:
             pass
     return tool, message
开发者ID:HullUni-bioinformatics,项目名称:ReproPhyloGalaxy,代码行数:26,代码来源:tool_validator.py

示例3: add_to_shed_tool_config

 def add_to_shed_tool_config( self, shed_tool_conf_dict, elem_list ):
     """
     "A tool shed repository is being installed so change the shed_tool_conf file.  Parse the
     config file to generate the entire list of config_elems instead of using the in-memory list
     since it will be a subset of the entire list if one or more repositories have been deactivated.
     """
     if not elem_list:
         # We may have an empty elem_list in case a data manager is being installed.
         # In that case we don't want to wait for a toolbox reload that will never happen.
         return
     shed_tool_conf = shed_tool_conf_dict[ 'config_filename' ]
     tool_path = shed_tool_conf_dict[ 'tool_path' ]
     config_elems = []
     tree, error_message = xml_util.parse_xml( shed_tool_conf )
     if tree:
         root = tree.getroot()
         for elem in root:
             config_elems.append( elem )
         # Add the new elements to the in-memory list of config_elems.
         for elem_entry in elem_list:
             config_elems.append( elem_entry )
         # Persist the altered shed_tool_config file.
         toolbox = self.app.toolbox
         self.config_elems_to_xml_file( config_elems, shed_tool_conf, tool_path )
         self.app.wait_for_toolbox_reload(toolbox)
开发者ID:glormph,项目名称:galaxy,代码行数:25,代码来源:tool_panel_manager.py

示例4: create_user

def create_user( app ):
    user_info_config = os.path.abspath( os.path.join( app.config.root, 'lib/tool_shed/scripts/bootstrap_tool_shed', 'user_info.xml' ) )
    email = None
    password = None
    username = None
    tree, error_message = xml_util.parse_xml( user_info_config )
    if tree is None:
        print "The XML file ", user_info_config, " seems to be invalid, using defaults."
        email = '[email protected]'
        password = 'testuser'
        username = 'admin'
    else:
        root = tree.getroot()
        for elem in root:
            if elem.tag == 'email':
                email = elem.text
            elif elem.tag == 'password':
                password = elem.text
            elif elem.tag == 'username':
                username = elem.text
    if email and password and username:
        invalid_message = validate( email, password, username )
        if invalid_message:
            print invalid_message
        else:
            user = app.model.User( email=email )
            user.set_password_cleartext( password )
            user.username = username
            app.sa_session.add( user )
            app.sa_session.flush()
            app.model.security_agent.create_private_user_role( user )
            return user
    else:
        print "Missing required values for email: ", email, ", password: ", password, ", username: ", username
    return None
开发者ID:BinglanLi,项目名称:galaxy,代码行数:35,代码来源:create_user_with_api_key.py

示例5: __init__

 def __init__( self, root_dir=None, config=None ):
     self.tool_sheds = odict()
     self.tool_sheds_auth = odict()
     if root_dir and config:
         # Parse tool_sheds_conf.xml
         tree, error_message = xml_util.parse_xml( config )
         if tree is None:
             log.warning( "Unable to load references to tool sheds defined in file %s" % str( config ) )
         else:
             root = tree.getroot()
             log.debug( 'Loading references to tool sheds from %s' % config )
             for elem in root.findall( 'tool_shed' ):
                 try:
                     name = elem.get( 'name', None )
                     url = elem.get( 'url', None )
                     username = elem.get( 'user', None )
                     password = elem.get( 'pass', None )
                     if name and url:
                         self.tool_sheds[ name ] = url
                         self.tool_sheds_auth[ name ] = None
                         log.debug( 'Loaded reference to tool shed: %s' % name )
                     if name and url and username and password:
                         pass_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
                         pass_mgr.add_password( None, url, username, password )
                         self.tool_sheds_auth[ name ] = pass_mgr
                 except Exception, e:
                     log.warning( 'Error loading reference to tool shed "%s", problem: %s' % ( name, str( e ) ) )
开发者ID:knowingchaos,项目名称:galaxy,代码行数:27,代码来源:tool_shed_registry.py

示例6: remove_from_shed_tool_config

 def remove_from_shed_tool_config( self, shed_tool_conf_dict, guids_to_remove ):
     """
     A tool shed repository is being uninstalled so change the shed_tool_conf file.
     Parse the config file to generate the entire list of config_elems instead of
     using the in-memory list since it will be a subset of the entire list if one
     or more repositories have been deactivated.
     """
     shed_tool_conf = shed_tool_conf_dict[ 'config_filename' ]
     tool_path = shed_tool_conf_dict[ 'tool_path' ]
     config_elems = []
     tree, error_message = xml_util.parse_xml( shed_tool_conf )
     if tree:
         root = tree.getroot()
         for elem in root:
             config_elems.append( elem )
         config_elems_to_remove = []
         for config_elem in config_elems:
             if config_elem.tag == 'section':
                 tool_elems_to_remove = []
                 for tool_elem in config_elem:
                     if tool_elem.get( 'guid' ) in guids_to_remove:
                         tool_elems_to_remove.append( tool_elem )
                 for tool_elem in tool_elems_to_remove:
                     # Remove all of the appropriate tool sub-elements from the section element.
                     config_elem.remove( tool_elem )
                 if len( config_elem ) < 1:
                     # Keep a list of all empty section elements so they can be removed.
                     config_elems_to_remove.append( config_elem )
             elif config_elem.tag == 'tool':
                 if config_elem.get( 'guid' ) in guids_to_remove:
                     config_elems_to_remove.append( config_elem )
         for config_elem in config_elems_to_remove:
             config_elems.remove( config_elem )
         # Persist the altered in-memory version of the tool config.
         self.config_elems_to_xml_file( config_elems, shed_tool_conf, tool_path )
开发者ID:HullUni-bioinformatics,项目名称:ReproPhyloGalaxy,代码行数:35,代码来源:tool_panel_manager.py

示例7: filter_and_persist_proprietary_tool_panel_configs

 def filter_and_persist_proprietary_tool_panel_configs( self, tool_configs_to_filter ):
     """Eliminate all entries in all non-shed-related tool panel configs for all tool config file names in the received tool_configs_to_filter."""
     for proprietary_tool_conf in self.proprietary_tool_confs:
         persist_required = False
         tree, error_message = xml_util.parse_xml( proprietary_tool_conf )
         if tree:
             root = tree.getroot()
             for elem in root:
                 if elem.tag == 'tool':
                     # Tools outside of sections.
                     file_path = elem.get( 'file', None )
                     if file_path:
                         if file_path in tool_configs_to_filter:
                             root.remove( elem )
                             persist_required = True
                 elif elem.tag == 'section':
                     # Tools contained in a section.
                     for section_elem in elem:
                         if section_elem.tag == 'tool':
                             file_path = section_elem.get( 'file', None )
                             if file_path:
                                 if file_path in tool_configs_to_filter:
                                     elem.remove( section_elem )
                                     persist_required = True
         if persist_required:
             fh = tempfile.NamedTemporaryFile( 'wb', prefix="tmp-toolshed-fapptpc"  )
             tmp_filename = fh.name
             fh.close()
             fh = open( tmp_filename, 'wb' )
             tree.write( tmp_filename, encoding='utf-8', xml_declaration=True )
             fh.close()
             shutil.move( tmp_filename, os.path.abspath( proprietary_tool_conf ) )
             os.chmod( proprietary_tool_conf, 0644 )
开发者ID:HullUni-bioinformatics,项目名称:ReproPhyloGalaxy,代码行数:33,代码来源:tool_migration_manager.py

示例8: get_archives_from_manifest

def get_archives_from_manifest( manifest_file_path ):
    """
    Return the list of archive names defined in the capsule manifest.  This method sill validate the manifest by ensuring all
    <repository> tag sets contain a valid <archive> sub-element.
    """
    archives = []
    error_message = ''
    manifest_tree, error_message = xml_util.parse_xml( manifest_file_path )
    if error_message:
        return archives, error_message
    manifest_root = manifest_tree.getroot()
    for elem in manifest_root:
        # <repository name="package_lapack_3_4" type="tool_dependency_definition" username="test">
        if elem.tag != 'repository':
            error_message = 'All level one sub-elements in the manifest.xml file must be <repository> tag sets.  '
            error_message += 'The tag <b><%s></b> is invalid.' % str( elem.tag )
            return [], error_message
        archive_file_name = None
        for repository_elem in elem:
            if repository_elem.tag == 'archive':
                # <archive>package_lapack_3_4-9e7a45ad3522.tar.gz</archive>
                archive_file_name = repository_elem.text
                break
        if archive_file_name is None:
            error_message = 'The %s tag set is missing a required <archive> sub-element.' % str( elem.tag )
            return [], error_message
        archives.append( archive_file_name )
    return archives, error_message
开发者ID:knowingchaos,项目名称:galaxy-central,代码行数:28,代码来源:import_util.py

示例9: handle_tag_attributes

 def handle_tag_attributes( self, config ):
     """
     Populate or unpopulate the toolshed and changeset_revision attributes of a
     <repository> tag.  Populating will occur when a dependency definition file
     is being uploaded to the repository, while unpopulating will occur when the
     repository is being exported.
     """
     # Make sure we're looking at a valid repository_dependencies.xml file.
     tree, error_message = xml_util.parse_xml( config )
     if tree is None:
         return False, None, error_message
     root = tree.getroot()
     root_altered = False
     new_root = copy.deepcopy( root )
     for index, elem in enumerate( root ):
         if elem.tag == 'repository':
             # <repository name="molecule_datatypes" owner="test" changeset_revision="1a070566e9c6" />
             altered, new_elem, error_message = self.handle_elem( elem )
             if error_message:
                 error_message = 'The %s file contains an invalid <repository> tag.  %s' % ( self.file_name, error_message )
                 return False, None, error_message
             if altered:
                 if not root_altered:
                     root_altered = True
                 new_root[ index ] = new_elem
     return root_altered, new_root, error_message
开发者ID:AbhishekKumarSingh,项目名称:galaxy,代码行数:26,代码来源:attribute_handlers.py

示例10: handle_repository_dependencies_definition

def handle_repository_dependencies_definition( trans, repository_dependencies_config, unpopulate=False ):
    """
    Populate or unpopulate the toolshed and changeset_revision attributes of a <repository> tag.  Populating will occur when a
    dependency definition file is being uploaded to the repository, while depopulating will occur when the repository is being
    exported.
    """
    altered = False
    # Make sure we're looking at a valid repository_dependencies.xml file.
    tree, error_message = xml_util.parse_xml( repository_dependencies_config )
    if tree is None:
        return False, None, error_message
    root = tree.getroot()
    if root.tag == 'repositories':
        for index, elem in enumerate( root ):
            if elem.tag == 'repository':
                # <repository name="molecule_datatypes" owner="test" changeset_revision="1a070566e9c6" />
                revised, elem, error_message = handle_repository_dependency_elem( trans, elem, unpopulate=unpopulate )
                if error_message:
                    error_message = 'The repository_dependencies.xml file contains an invalid <repository> tag.  %s' % error_message
                    return False, None, error_message
                if revised:
                    root[ index ] = elem
                    if not altered:
                        altered = True
        return altered, root, error_message
    return False, None, error_message
开发者ID:knowingchaos,项目名称:galaxy-central,代码行数:26,代码来源:commit_util.py

示例11: get_proprietary_tool_panel_elems

 def get_proprietary_tool_panel_elems( self, latest_tool_migration_script_number ):
     """
     Parse each config in self.proprietary_tool_confs (the default is tool_conf.xml) and generate a list of Elements that are
     either ToolSection elements or Tool elements.  These will be used to generate new entries in the migrated_tools_conf.xml
     file for the installed tools.
     """
     tools_xml_file_path = os.path.abspath( os.path.join( 'scripts', 'migrate_tools', '%04d_tools.xml' % latest_tool_migration_script_number ) )
     # Parse the XML and load the file attributes for later checking against the integrated elements from self.proprietary_tool_confs.
     migrated_tool_configs = []
     tree, error_message = xml_util.parse_xml( tools_xml_file_path )
     if tree is None:
         return []
     root = tree.getroot()
     for elem in root:
         if elem.tag == 'repository':
             for tool_elem in elem:
                 migrated_tool_configs.append( tool_elem.get( 'file' ) )
     # Parse each file in self.proprietary_tool_confs and generate the integrated list of tool panel Elements that contain them.
     tool_panel_elems = []
     for proprietary_tool_conf in self.proprietary_tool_confs:
         tree, error_message = xml_util.parse_xml( proprietary_tool_conf )
         if tree is None:
             return []
         root = tree.getroot()
         for elem in root:
             if elem.tag == 'tool':
                 # Tools outside of sections.
                 file_path = elem.get( 'file', None )
                 if file_path:
                     name = suc.strip_path( file_path )
                     if name in migrated_tool_configs:
                         if elem not in tool_panel_elems:
                             tool_panel_elems.append( elem )
             elif elem.tag == 'section':
                 # Tools contained in a section.
                 for section_elem in elem:
                     if section_elem.tag == 'tool':
                         file_path = section_elem.get( 'file', None )
                         if file_path:
                             name = suc.strip_path( file_path )
                             if name in migrated_tool_configs:
                                 # Append the section, not the tool.
                                 if elem not in tool_panel_elems:
                                     tool_panel_elems.append( elem )
     return tool_panel_elems
开发者ID:Pelonza,项目名称:Learn2Mine-Main,代码行数:45,代码来源:install_manager.py

示例12: install_tool_data_tables

 def install_tool_data_tables( self, tool_shed_repository, tool_index_sample_files ):
     TOOL_DATA_TABLE_FILE_NAME = 'tool_data_table_conf.xml'
     TOOL_DATA_TABLE_FILE_SAMPLE_NAME = '%s.sample' % ( TOOL_DATA_TABLE_FILE_NAME )
     SAMPLE_SUFFIX = '.sample'
     SAMPLE_SUFFIX_OFFSET = -len( SAMPLE_SUFFIX )
     tool_path, relative_target_dir = tool_shed_repository.get_tool_relative_path( self.app )
     # This is where index files will reside on a per repo/installed version basis.
     target_dir = os.path.join( self.app.config.shed_tool_data_path, relative_target_dir )
     if not os.path.exists( target_dir ):
         os.makedirs( target_dir )
     for sample_file in tool_index_sample_files:
         path, filename = os.path.split ( sample_file )
         target_filename = filename
         if target_filename.endswith( SAMPLE_SUFFIX ):
             target_filename = target_filename[ : SAMPLE_SUFFIX_OFFSET ]
         source_file = os.path.join( tool_path, sample_file )
         # We're not currently uninstalling index files, do not overwrite existing files.
         target_path_filename = os.path.join( target_dir, target_filename )
         if not os.path.exists( target_path_filename ) or target_filename == TOOL_DATA_TABLE_FILE_NAME:
             shutil.copy2( source_file, target_path_filename )
         else:
             log.debug( "Did not copy sample file '%s' to install directory '%s' because file already exists.", filename, target_dir )
         # For provenance and to simplify introspection, let's keep the original data table sample file around.
         if filename == TOOL_DATA_TABLE_FILE_SAMPLE_NAME:
             shutil.copy2( source_file, os.path.join( target_dir, filename ) )
     tool_data_table_conf_filename = os.path.join( target_dir, TOOL_DATA_TABLE_FILE_NAME )
     elems = []
     if os.path.exists( tool_data_table_conf_filename ):
         tree, error_message = xml_util.parse_xml( tool_data_table_conf_filename )
         if tree:
             for elem in tree.getroot():
                 # Append individual table elems or other elemes, but not tables elems.
                 if elem.tag == 'tables':
                     for table_elem in elems:
                         elems.append( elem )
                 else:
                     elems.append( elem )
     else:
         log.debug( "The '%s' data table file was not found, but was expected to be copied from '%s' during repository installation.",
                    tool_data_table_conf_filename, TOOL_DATA_TABLE_FILE_SAMPLE_NAME )
     for elem in elems:
         if elem.tag == 'table':
             for file_elem in elem.findall( 'file' ):
                 path = file_elem.get( 'path', None )
                 if path:
                     file_elem.set( 'path', os.path.normpath( os.path.join( target_dir, os.path.split( path )[1] ) ) )
             # Store repository info in the table tag set for trace-ability.
             repo_elem = self.generate_repository_info_elem_from_repository( tool_shed_repository, parent_elem=elem )
     if elems:
         # Remove old data_table
         os.unlink( tool_data_table_conf_filename )
         # Persist new data_table content.
         self.app.tool_data_tables.to_xml_file( tool_data_table_conf_filename, elems )
     return tool_data_table_conf_filename, elems
开发者ID:HullUni-bioinformatics,项目名称:ReproPhyloGalaxy,代码行数:54,代码来源:data_table_manager.py

示例13: generate_tool_panel_dict_from_shed_tool_conf_entries

 def generate_tool_panel_dict_from_shed_tool_conf_entries( self, repository ):
     """
     Keep track of the section in the tool panel in which this repository's
     tools will be contained by parsing the shed_tool_conf in which the
     repository's tools are defined and storing the tool panel definition
     of each tool in the repository. This method is called only when the
     repository is being deactivated or un-installed and allows for
     activation or re-installation using the original layout.
     """
     tool_panel_dict = {}
     shed_tool_conf, tool_path, relative_install_dir = \
         suc.get_tool_panel_config_tool_path_install_dir( self.app, repository )
     metadata = repository.metadata
     # Create a dictionary of tool guid and tool config file name for each tool in the repository.
     guids_and_configs = {}
     if 'tools' in metadata:
         for tool_dict in metadata[ 'tools' ]:
             guid = tool_dict[ 'guid' ]
             tool_config = tool_dict[ 'tool_config' ]
             file_name = basic_util.strip_path( tool_config )
             guids_and_configs[ guid ] = file_name
     # Parse the shed_tool_conf file in which all of this repository's tools are defined and generate the tool_panel_dict.
     tree, error_message = xml_util.parse_xml( shed_tool_conf )
     if tree is None:
         return tool_panel_dict
     root = tree.getroot()
     for elem in root:
         if elem.tag == 'tool':
             guid = elem.get( 'guid' )
             if guid in guids_and_configs:
                 # The tool is displayed in the tool panel outside of any tool sections.
                 tool_section_dict = dict( tool_config=guids_and_configs[ guid ], id='', name='', version='' )
                 if guid in tool_panel_dict:
                     tool_panel_dict[ guid ].append( tool_section_dict )
                 else:
                     tool_panel_dict[ guid ] = [ tool_section_dict ]
         elif elem.tag == 'section':
             section_id = elem.get( 'id' ) or ''
             section_name = elem.get( 'name' ) or ''
             section_version = elem.get( 'version' ) or ''
             for section_elem in elem:
                 if section_elem.tag == 'tool':
                     guid = section_elem.get( 'guid' )
                     if guid in guids_and_configs:
                         # The tool is displayed in the tool panel inside the current tool section.
                         tool_section_dict = dict( tool_config=guids_and_configs[ guid ],
                                                   id=section_id,
                                                   name=section_name,
                                                   version=section_version )
                         if guid in tool_panel_dict:
                             tool_panel_dict[ guid ].append( tool_section_dict )
                         else:
                             tool_panel_dict[ guid ] = [ tool_section_dict ]
     return tool_panel_dict
开发者ID:BenjaminHCCarr,项目名称:galaxy,代码行数:54,代码来源:tool_panel_manager.py

示例14: handle_tool_dependencies

def handle_tool_dependencies( app, tool_shed_repository, tool_dependencies_config, tool_dependencies ):
    """
    Install and build tool dependencies defined in the tool_dependencies_config.  This config's tag sets can currently refer to installation
    methods in Galaxy's tool_dependencies module.  In the future, proprietary fabric scripts contained in the repository will be supported.
    Future enhancements to handling tool dependencies may provide installation processes in addition to fabric based processes.  The dependencies
    will be installed in:
    ~/<app.config.tool_dependency_dir>/<package_name>/<package_version>/<repo_owner>/<repo_name>/<repo_installed_changeset_revision>
    """
    sa_session = app.model.context.current
    installed_tool_dependencies = []
    # Parse the tool_dependencies.xml config.
    tree, error_message = xml_util.parse_xml( tool_dependencies_config )
    if tree is None:
        return installed_tool_dependencies
    root = tree.getroot()
    fabric_version_checked = False
    for elem in root:
        if elem.tag == 'package':
            # Only install the tool_dependency if it is not already installed.
            package_name = elem.get( 'name', None )
            package_version = elem.get( 'version', None )
            if package_name and package_version:
                for tool_dependency in tool_dependencies:
                    if tool_dependency.name==package_name and tool_dependency.version==package_version:
                        break
                if tool_dependency.can_install:
                    try:
                        tool_dependency = install_package( app, elem, tool_shed_repository, tool_dependencies=tool_dependencies )
                    except Exception, e:
                        error_message = "Error installing tool dependency %s version %s: %s" % ( str( package_name ), str( package_version ), str( e ) )
                        log.debug( error_message )
                        if tool_dependency:
                            tool_dependency.status = app.model.ToolDependency.installation_status.ERROR
                            tool_dependency.error_message = error_message
                            sa_session.add( tool_dependency )
                            sa_session.flush()
                    if tool_dependency and tool_dependency.status in [ app.model.ToolDependency.installation_status.INSTALLED,
                                                                       app.model.ToolDependency.installation_status.ERROR ]:
                        installed_tool_dependencies.append( tool_dependency )
        elif elem.tag == 'set_environment':
            try:
                tool_dependency = set_environment( app, elem, tool_shed_repository )
            except Exception, e:
                error_message = "Error setting environment for tool dependency: %s" % str( e )
                log.debug( error_message )
                if tool_dependency:
                    tool_dependency.status = app.model.ToolDependency.installation_status.ERROR
                    tool_dependency.error_message = error_message
                    sa_session.add( tool_dependency )
                    sa_session.flush()
开发者ID:knowingchaos,项目名称:galaxy,代码行数:50,代码来源:common_install_util.py

示例15: get_non_shed_tool_panel_configs

def get_non_shed_tool_panel_configs(app):
    """Get the non-shed related tool panel configs - there can be more than one, and the default is tool_conf.xml."""
    config_filenames = []
    for config_filename in app.config.tool_configs:
        # Any config file that includes a tool_path attribute in the root tag set like the following is shed-related.
        # <toolbox tool_path="../shed_tools">
        tree, error_message = xml_util.parse_xml(config_filename)
        if tree is None:
            continue
        root = tree.getroot()
        tool_path = root.get('tool_path', None)
        if tool_path is None:
            config_filenames.append(config_filename)
    return config_filenames
开发者ID:ImmPortDB,项目名称:immport-galaxy,代码行数:14,代码来源:common_util.py


注:本文中的tool_shed.util.xml_util.parse_xml函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。