示例#1
0
文件: scan.py 项目: tomspur/euscan
def scan_upstream_urls(cpv, urls):
    versions = []

    for filename in urls:
        for url in urls[filename]:
            if not CONFIG['quiet']:
                pp.uprint()
            euscan.output.einfo("SRC_URI is '%s'" % url)

            if '://' not in url:
                euscan.output.einfo("Invalid url '%s'" % url)
                continue

            ''' Try normal scan '''
            if CONFIG["scan-dir"]:
                versions.extend(handlers.scan(cpv, url))

            if versions and CONFIG['oneshot']:
                break

            ''' Brute Force '''
            if CONFIG["brute-force"] > 0:
                versions.extend(handlers.brute_force(cpv, url))

            if versions and CONFIG['oneshot']:
                break

    cp, ver, rev = portage.pkgsplit(cpv)
    return filter_versions(cp, versions)
示例#2
0
文件: scan.py 项目: mgorny/euscan
def scan_upstream_urls(cpv, urls, on_progress):
    versions = []

    maxval = len(urls) + 5
    curval = 1

    for filename in urls:
        curval += 1
        if on_progress:
            on_progress(maxval, curval)

        for url in urls[filename]:
            if not CONFIG['quiet'] and not CONFIG['format']:
                pp.uprint()
            output.einfo("SRC_URI is '%s'" % url)

            if '://' not in url:
                output.einfo("Invalid url '%s'" % url)
                continue

            # Try normal scan
            if CONFIG["scan-dir"]:
                try:
                    versions.extend(handlers.scan(cpv, url))
                except Exception as e:
                    output.ewarn("Handler failed: [%s] %s"
                            % (e.__class__.__name__, e.message))

            if versions and CONFIG['oneshot']:
                break

            # Brute Force
            if CONFIG["brute-force"] > 0:
                versions.extend(handlers.brute_force(cpv, url))

            if versions and CONFIG['oneshot']:
                break

    cp, ver, rev = portage.pkgsplit(cpv)

    curval += 1
    if on_progress:
        on_progress(maxval, curval)

    result = filter_versions(cp, versions)

    curval += 1
    if on_progress:
        on_progress(maxval, curval)

    return result