Beispiel #1
0
def find_urls_for_xml(root):
    """Returns two lists: explicit package URLs, and help text URLs.

    For validating the user-facing URLs is it sensible to mimic
    a web browser user agent.
    """
    urls = []
    for packages in root.findall("package"):
        install_els = packages.findall("install")
        assert len(install_els) in (0, 1)

        if len(install_els) == 0:
            continue

        install_el = install_els[0]
        package = BasePackage(None, packages, install_el, readme=None)
        for action in package.get_all_actions():
            urls.extend([dl.url for dl in action.downloads()])

            for subaction in action.actions:
                if hasattr(subaction, 'packages'):
                    urls.extend(subaction.packages)

    docs = []
    for help_text in root.findall("help"):
        for url in _find_urls_in_text(help_text.text):
            docs.append(url[0])

    return urls, docs
Beispiel #2
0
def find_urls_for_xml(root):
    """Returns two lists: explicit package URLs, and help text URLs.

    For validating the user-facing URLs is it sensible to mimic
    a web browser user agent.
    """
    urls = []
    for packages in root.findall("package"):
        install_els = packages.findall("install")
        assert len(install_els) in (0, 1)

        if len(install_els) == 0:
            continue

        install_el = install_els[0]
        package = BasePackage(None, packages, install_el, readme=None)
        for action in package.get_all_actions():
            urls.extend([dl.url for dl in action.downloads()])

            for subaction in action.actions:
                if hasattr(subaction, 'packages'):
                    urls.extend(subaction.packages)

    docs = []
    for help_text in root.findall("help"):
        for url in _find_urls_in_text(help_text.text):
            docs.append(url[0])

    return urls, docs
def convert_tool_dep(dependencies_file):
    """Parse a tool_dependencies.xml into install.sh and env.sh commands.

    Returns two lists of strings, commands to add to install.sh and
    env.sh respectively.
    """
    install_cmds = []
    env_cmds = []

    root = ET.parse(dependencies_file).getroot()
    package_els = root.findall("package")

    packages = []
    dependencies = []
    for package_el in package_els:
        install_els = package_el.findall("install")
        assert len(install_els) in (0, 1)
        if len(install_els) == 0:
            repository_el = package_el.find("repository")
            assert repository_el is not None, "no repository in %s" % repository_el
            dependencies.append(Dependency(None, package_el, repository_el))
        else:
            install_el = install_els[0]
            packages.append(
                BasePackage(None, package_el, install_el, readme=None))

    if not packages:
        info("No packages in %s" % dependencies_file)
        return [], []

    assert len(packages) == 1, packages
    package = packages[0]
    name = package_el.attrib["name"]
    version = package_el.attrib["version"]

    # TODO - Set $INSTALL_DIR in the script
    # os.environ["INSTALL_DIR"] = os.path.abspath(os.curdir)
    for action in package.all_actions:
        inst, env = action.to_bash()
        install_cmds.extend(inst)
        env_cmds.extend(env)

    if install_cmds:
        install_cmds.insert(0, 'cd $dep_install_tmp')
        install_cmds.insert(0, 'specifc_action_done=0')
        install_cmds.insert(0, 'echo "%s"' % ('=' * 60))
        install_cmds.insert(
            0, 'echo "Installing %s version %s"' % (name, version))
        install_cmds.insert(0, 'echo "%s"' % ('=' * 60))
    if env_cmds:
        env_cmds.insert(0, 'specifc_action_done=0')
        env_cmds.insert(0, '#' + '=' * 60)
        env_cmds.insert(
            0, 'echo "Setting environment variables for %s version %s"' %
            (name, version))
        env_cmds.insert(0, '#' + '=' * 60)
        # TODO - define $INSTALL_DIR here?

    return install_cmds, env_cmds
Beispiel #4
0
def find_urls_for_xml(root):
    urls = []
    for packages in root.findall("package"):
        install_els = packages.findall("install")
        assert len(install_els) in (0, 1)

        if len(install_els) == 0:
            continue

        install_el = install_els[0]
        package = BasePackage(None, packages, install_el, readme=None)
        for action in package.get_all_actions():
            urls.extend([dl.url for dl in action.downloads()])

            for subaction in action.actions:
                if hasattr(subaction, 'packages'):
                    urls.extend(subaction.packages)

    for help_text in root.findall("help"):
        for url in HTTP_REGEX_PATTERN.findall(help_text.text):
            urls.append(url[0])

    return urls
Beispiel #5
0
def find_urls_for_xml(root):
    urls = []
    for packages in root.findall("package"):
        install_els = packages.findall("install")
        assert len(install_els) in (0, 1)

        if len(install_els) == 0:
            continue

        install_el = install_els[0]
        package = BasePackage(None, packages, install_el, readme=None)
        for action in package.get_all_actions():
            urls.extend([dl.url for dl in action.downloads()])

            for subaction in action.actions:
                if hasattr(subaction, 'packages'):
                    urls.extend(subaction.packages)

    for help_text in root.findall("help"):
        for url in HTTP_REGEX_PATTERN.findall(help_text.text):
            urls.append(url[0])

    return urls