Exemplo n.º 1
0
def find_updates(pkgset, stable_only=True):
    no_releases = set()

    def write(s):
        sys.stdout.write(s)
        sys.stdout.flush()

    pypi = Server("http://pypi.python.org/pypi/")
    pkgname2latest = {}

    pkgfiles = [pkgfile(x) for x in pkgset.find_packages()]

    for x in pkgfiles:
        if x.pkgname not in pkgname2latest:
            pkgname2latest[x.pkgname] = x
        elif x.version_info > pkgname2latest[x.pkgname].version_info:
            pkgname2latest[x.pkgname] = x

    need_update = []

    sys.stdout.write("checking %s packages for newer version\n" % len(pkgname2latest),)
    for count, (pkgname, file) in enumerate(pkgname2latest.items()):
        if count % 40 == 0:
            write("\n")

        releases = pypi.package_releases(pkgname)

        releases = [(parse_version(x), x) for x in releases]
        if stable_only:
            releases = filter_stable_releases(releases)

        status = "."
        if releases:
            m = max(releases)
            if m[0] > file.version_info:
                file.latest_version = m[1]
                status = "u"
                # print "%s needs update from %s to %s" % (pkgname, file.version, m[1])
                need_update.append(file)
        else:
            no_releases.add(pkgname)
            status = "e"

        write(status)

    write("\n\n")

    no_releases = list(no_releases)
    if no_releases:
        no_releases.sort()
        sys.stdout.write("no releases found on pypi for %s\n\n" % (", ".join(no_releases),))
    return need_update
Exemplo n.º 2
0
def latest_release(package):
    """Retrieve latest released data."""
        
    url = 'http://pypi.python.org/pypi'
    LOGGER.info("Connecting to '{0:s}'.".format(url))
    if _PY3K:
        from xmlrpc.client import Server
    else:
        from xmlrpclib import Server
    pypi = Server(url)
    
    show_hidden = False
    releases = pypi.package_releases(package, show_hidden)
    
    for release in releases:
        urls = pypi.release_urls(package, release)
        return urls
Exemplo n.º 3
0
def latest_release(package):
    """Retrieve latest released data."""

    url = 'http://pypi.python.org/pypi'
    LOGGER.info("Connecting to '{0:s}'.".format(url))
    if _PY3K:
        from xmlrpc.client import Server
    else:
        from xmlrpclib import Server
    pypi = Server(url)

    show_hidden = False
    releases = pypi.package_releases(package, show_hidden)

    for release in releases:
        urls = pypi.release_urls(package, release)
        return urls
Exemplo n.º 4
0
def mirror(package_name, destdir=None, dry_run=False, stable_only=True):

    pypi = Server("http://pypi.python.org/pypi/")

    versions = pypi.package_releases(package_name)

    command_base = ('pip -q install --no-deps -i http://pypi.python.org/simple'
                    ' -I -d %s %s==' % (destdir, package_name))

    commands = [('%s%s' % (command_base, version), version)
                for version in versions]

    for command, version in commands:
        print "Mirroring %s==%s" % (package_name, version)

        if not dry_run:
            running_command = subprocess.Popen(command, shell=True)
            running_command.communicate()[0]

        print "... completed mirror of %s at %s" % (package_name, version)