Last active
August 10, 2017 03:05
-
-
Save MichaelTunnell/8d290e2002bdbfb8ac7634d13c0be4a1 to your computer and use it in GitHub Desktop.
python script that pulls download stats data from Launchpad.net PPAs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from launchpadlib.launchpad import Launchpad | |
import os | |
import sys | |
USERNAME=sys.argv[1] | |
PPA=sys.argv[2] | |
PACKAGE=sys.argv[3] | |
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]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this was forked from springmeyer's gist, I added command line value input rather than hardcoded in the script.
Usage:
sudo apt install python-launchpadlib
Note: the
> launchpad-ppa-stats.txt
portion is not needed but this is to output to a text file where as by default the script outputs the data to the terminal.