Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# See https://api.launchpad.net/+apidoc/devel.html#binary_package_publishing_history
# See https://help.launchpad.net/API/launchpadlib
#Code from https://gist.github.com/springmeyer/2778600
from launchpadlib.launchpad import Launchpad
import os

USERNAME='iconnor'
PPA='zoneminder'
PACKAGE='zoneminder'

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])
print total
Python 2.7.10 (default, Jul 14 2015, 19:46:27) [GCC 4.8.2] on linux