Monday, April 29, 2024
 Popular · Latest · Hot · Upcoming
19
rated 0 times [  19] [ 0]  / answers: 1 / hits: 3451  / 1 Year ago, sat, march 11, 2023, 2:26:21

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?


More From » ppa

 Answers
0

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 ' ' ',' | 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 + " " + individualarchive.binary_package_version + " " + str(individualarchive.getDownloadCount())
elif x < 1:
print '0'


To use it:



python ppastats.py webupd8team themes natty i386

[#31173] Saturday, March 11, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mouedi

Total Points: 420
Total Questions: 109
Total Answers: 116

Location: Philippines
Member since Wed, Aug 19, 2020
4 Years ago
;