Skip to content

Instantly share code, notes, and snippets.

@springmeyer
Created May 24, 2012 00:26
Show Gist options
  • Save springmeyer/2778600 to your computer and use it in GitHub Desktop.
Save springmeyer/2778600 to your computer and use it in GitHub Desktop.

Revisions

  1. Dane Springmeyer created this gist May 24, 2012.
    26 changes: 26 additions & 0 deletions launchpad_stats.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    # See https://api.launchpad.net/+apidoc/devel.html#binary_package_publishing_history
    # See https://help.launchpad.net/API/launchpadlib

    from launchpadlib.launchpad import Launchpad
    import os

    USERNAME='developmentseed'
    PPA='mapbox'
    PACKAGE='tilemill'

    cachedir = os.environ['HOME'] + '/.launchpadlib/cache/'
    launchpad = Launchpad.login_anonymously('just testing', 'production', cachedir)

    ppa = launchpad.people[USERNAME].getPPAByName(name=PPA)
    bins = ppa.getPublishedBinaries(binary_name=PACKAGE)
    builds = []
    total = 0
    for bin in bins:
    count = bin.getDownloadCount()
    total += count
    if (count > 0):
    builds.append([count,'%s %s' % (bin.binary_package_name,bin.binary_package_version)])

    builds_sorted = sorted(builds,key=lambda count: count[0],reverse=True)
    for build in builds_sorted:
    print '%s:%s' % (build[0], build[1])