still don't have a title

Introducing python-popcon

Python-popcon is a small Python library which allows to query Debian’s popcon database. The usage is very trivial:

>>> import popcon

>>> popcon.package('python-popcon')
{'python-popcon': 2}

>>> popcon.package('icedove', 'iceweasel')
{'icedove': 12140, 'iceweasel': 45666}

>>> popcon.package('foobarbaz')
{}

You can call the package method with an arbitrary number of package names and it will return a dictionary with package name : popcon value mappings for all packages found. If a package is not found in the popcon database it will not be in the resulting dictionary or if it was the only package in the method call, the method will return an empty dictionary. The popcon value is the number of installations according to Debian’s Popularity Contest service.

There is also a second method which gives some more information

>>> popcon.package_raw('icedove', 'iceweasel')
{'icedove': [8065, 2195, 1879, 1], 'iceweasel': [27857, 10681, 7120, 8]}

It returns a list of [vote, old, recent, no-files] for the given package.

How does it work? Upon a query, popcon downloads https://popcon.debian.org/all-popcon-results.txt.gz, extracts and parses the file and returns the desired information. Since downloading and extraction this file is expensive, it saves the file and tries to re-use it is not older than 7 days. So while the first call of one of the above methods can take a few seconds, the result will appear almost instantaneously for the next week until the cache file expired.

That’s it, no rocket science but a convenient way to get popcon information from within python. The package python-popcon is available in Debian/Sid for a few days.