Example #1
0
def add_xml_files(galaxy_root, module_names, short_name_length, tools_subdir):
    """
    The XML files are added under two conditions.
    Under the first condition the files are added directly to galaxy.
    In this case only the XML filenames are subsequently needed to
    create the toolbox XML file.
    Under the second condition the files are added to a tool suite archive.
    In this case the id, name, and description of the added modules
    are needed to create the suite configuration XML file.
    This function is concerned with the first case.
    @param galaxy_root: root of the galaxy installation
    @param module_names: generally uninformative names of modules
    @param short_name_length: max length of unique short module names
    @param tools_subdir: subdirectory of galaxy_root
    @return: a list of xml filenames, and a list of import errors
    """
    mod_infos, import_errors = meta.get_usermod_info(
            module_names, short_name_length)
    # Get the xmls.
    xml_filenames = []
    nsuccesses = 0
    nfailures = 0
    for info in mod_infos:
        usermod = info.get_usermod()
        name = info.get_name()
        short_name = info.get_identifier()
        xml_content = None
        try:
            xml_content = get_xml(usermod, name, short_name)
            nsuccesses += 1
        except Exception as e:
            print >> sys.stderr, '%s: error making xml: %s' % (name, str(e))
            nfailures += 1
        if xml_content:
            xml_filename = short_name + '.xml'
            xml_pathname = os.path.join(
                    galaxy_root, 'tools', tools_subdir, xml_filename)
            with open(xml_pathname, 'w') as fout:
                fout.write(xml_content)
            xml_filenames.append(xml_filename)
    print >> sys.stderr, len(import_errors), 'import errors'
    print >> sys.stderr, nfailures, 'failures to create an xml'
    print >> sys.stderr, nsuccesses, 'successfully created xmls'
    return xml_filenames, import_errors
Example #2
0
def add_xml_files(cat_info, env_info,
        module_names, short_name_length, local_xml_dir, runbsub):
    """
    @param cat_info: how xmls will be categorized
    @param env_info: relevant places in the filesystem
    @param module_names: generally uninformative names of modules
    @param short_name_length: max length of unique short module names
    @param local_xml_dir: usually the xml dir in env_info
    #param runbsub: a path to a python script
    @return: a command
    """
    mod_infos, import_errors = meta.get_usermod_info(
            module_names, short_name_length)
    # Get the xmls.
    nsuccesses = 0
    nfailures = 0
    for info in mod_infos:
        usermod = info.get_usermod()
        name = info.get_name()
        short_name = info.get_identifier()
        xml_content = None
        try:
            xml_content = get_xml(
                    cat_info, env_info, usermod, name, short_name, runbsub)
            nsuccesses += 1
        except Exception as e:
            print >> sys.stderr, '%s: error making xml: %s' % (name, str(e))
            nfailures += 1
        if xml_content:
            xml_filename = os.path.join(local_xml_dir, short_name + '.xml')
            with open(xml_filename, 'w') as fout:
                fout.write(xml_content)
    print >> sys.stderr, len(import_errors), 'import errors'
    print >> sys.stderr, nfailures, 'failures to create an xml'
    print >> sys.stderr, nsuccesses, 'successfully created xmls'
    return [x.get_identifier() for x in mod_infos], import_errors