Stats are fun

— 2013-03-03 —

Update: PyPi stopped serving stats in may 2013. The script in this blogpost will only be able to get download counts until may 24th. More information can be found on the distutils mailinglist. Anyways it was fun as long as it worked.

I recently stumbled over pypstats and wanted to combine it with the power of Geek Tool. I created a shells-script to download the stats regularly and print total downloads to a text-file.

To install pypstats use pip install pypstats

#!/bin/bash
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
cd ~/pypi-stats/
pyps update -q <project>
pyps total -q <project>_stats.pkl > <project>-total.txt

It is necessary to set the path beacause crontab does not run with a environment that includes /usr/local/bin, where pypstats is installed by pip. The -q makes the operations perform quietly.

Then in Geek Tools I just added this cat ~/pypi-stats/<project>-total.txt

    pypstats
    pypi
    stats
    geek-tool