16

I'd like to know how many downloads of a given package in a PPA there have been since it was first published.

I remember there was a bug about it about getting these metrics on the web UI, but as far as I know, it never got implemented.

But I think the number of downloads can nevertheless be obtained via the Launchpad API if I'm the owner of that PPA. Any pointers?

4 Answers 4

19

Check out this script:

#!/usr/bin/python2

# Usage python ppastats.py PPATEAM (ex: webupd8team) PPA (ex: gthumb) DIST (Ubuntu version eg maverick) ARCH (ubuntu arch eg i386 or amd64)
# Example - highest downloaded file: python ppastats.py webupd8team y-ppa-manager maverick amd64 | tr '\t' ',' | cut -d ',' -f3 | sort -gr

import sys
from launchpadlib.launchpad import Launchpad

PPAOWNER = sys.argv[1]
PPA = sys.argv[2]
desired_dist_and_arch = 'https://api.launchpad.net/devel/ubuntu/' + sys.argv[3] + '/' + sys.argv[4]

cachedir = "~/.launchpadlib/cache/"
lp_ = Launchpad.login_anonymously('ppastats', 'production', cachedir)
owner = lp_.people[PPAOWNER]
archive = owner.getPPAByName(name=PPA)

for individualarchive in archive.getPublishedBinaries(status='Published', distro_arch_series=desired_dist_and_arch):
    x = individualarchive.getDownloadCount()
    if x > 0:
        print individualarchive.binary_package_name + "\t" + individualarchive.binary_package_version + "\t" + str(individualarchive.getDownloadCount())
    elif x < 1:
        print '0'

To use it:

python ppastats.py webupd8team themes natty i386
3
  • 2
    sudo pip install launchpadlib && sudo pip install simplejson
    – OverCoder
    Jan 8, 2017 at 15:02
  • I took this and expanded it a bit: gist.github.com/nathan-osman/b9158d058cc45916dcd20a591b66d0b4 Now you no longer need to specify a binary and you get a nicely formatted table. Jul 14, 2017 at 16:56
  • What's the unit of this count? Total? Per month? Maybe a link to the underlying functions documentation would be great!? Thanks!
    – Matifou
    Jan 13, 2020 at 22:38
2

From the jfi/ppastats package, I managed to figure out how the API worked, and I made a userscript (Greasemonkey/Tampermonkey), that will neatly list the download count next to your packages. Make sure to go to the "View all builds" view, to which there is two links added in your package details. Patches for improvements are welcome!

8
  • whut? How does this work? How is this simpler than the accepted answer?
    – Kaz Wolfe
    Sep 26, 2014 at 8:02
  • It's a cross platform script that you run in your browser with either the Greasemonkey extension (Firefox) or the Tampermonkey extension (Chrome). I would say that it is simpler. Sep 26, 2014 at 17:21
  • Where are the download counts? I see "view download counts" but when I click that I don't see them anyway on the page..
    – Seth
    Oct 3, 2014 at 16:51
  • Strange. I tested the latest version with both Firefox and Chrome (Greasemonkey and Tampermonkey). Try going to my PPA (which is the one I made it for): launchpad.net/~stefansundin/+archive/ubuntu/truecrypt/… It may have some problems with an archive that has been copied between ubuntu versions, in which case you may see a spinner that never goes away. I'll try to solve this in a later version. Oct 4, 2014 at 23:54
  • Yes, going to your PPA works, but mine shows absolutely nothing. It is entirely possible no one has downloaded it yet, but ppastats seems to contradict that: paste.ubuntu.com/8752766 (Sorry I didn't reply earlier, but you didn't @ include me so I didn't see it until now)
    – Seth
    Oct 30, 2014 at 22:58
1

You can generate an HTML report containing statistics and graphs about download counts of a PPA with ppastats (http://wpitchoune.net/blog/ppastats/).

Here is an example: http://wpitchoune.net/ppastats/ppa/otto-kesselgulasch/gimp/.

If you are using Ubuntu, you can install it by using the PPA ppa:jfi/ppastats:

sudo apt-add-repository ppa:jfi/ppastats
sudo apt-get update
sudo apt-get install ppastats

Then to generate the HTML report:

ppastats [PPA_OWNER] [PPA_NAME] -o [OUTPUT_DIR]
6
  • 1
    There is no vivid package available yet :/
    – Seth
    Sep 15, 2015 at 13:59
  • ppastats is compiling fine on vivid, at least the version 1.3.3 (wpitchoune.net/ppastats/files/ppastats-1.3.3.tar.gz). The ubuntu packaging too, it can be built with git-buildpackage from the following git repository: git.wpitchoune.net/psensor-pkg-ubuntu.git. I will probably upload it publically at some point.
    – JeanFI
    Sep 16, 2015 at 21:34
  • I just installed the last available binary package, worked fine. You realize you could just have Launchpad rebuild the package for a newer release for you?
    – Seth
    Sep 18, 2015 at 2:23
  • There's no yakkety package :(
    – Seth
    Dec 18, 2016 at 6:41
  • As of today, the count on this ppa for xenial i386 is 1. There is a reputation aspect to knowing the count b4 installing a package that this doesn't pass well.... just sayin'
    – Rondo
    Jun 26, 2017 at 20:24
0

There is another python script available at:

https://bugs.launchpad.net/launchpad/+bug/139855/comments/66

DL: https://bugs.launchpad.net/launchpad/+bug/139855/+attachment/3217345/+files/ppastats

usage: ppastat.py [-h] [--all] [--arch ARCH] user [ppa [ppa ...]]

2
  • Welcome to AskUbuntu! Although this may possibly answer the question, there are no real explanations, and this might be better off as a comment.
    – No Time
    Oct 15, 2014 at 4:36
  • Does it require any special dependencies? Here on Trusty it fails with a IndexError: list index out of range error.
    – landroni
    Nov 28, 2015 at 15:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .