[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: wnppalert



> About two years ago, Arthur Korn posted a nifty script "wnppalert"
> 
>  http://lists.debian.org/debian-devel/2001/debian-devel-200103/msg01386.html
> 
> that scans the WNPP web pages for packages that are orphaned or up for
> adoption and are installed on your system.  

That is pretty nifty :)

> Since I'm lazy, I thought I'd ask whether someone else has already
> fixed up the script and could post it here for the benefit of all.

I'm lazy, but was a bit bored.  I've attached a short python script that
gets the same job done.

jack.
#!/usr/bin/env python
#
# wnpplist
#
# Prints a list of orphaned or RFA packages that are installed on the
# current Debian system.

import os, string, re
from urllib2 import urlopen
from popen2 import popen2

wnpp_re = re.compile("^<li><a href=\"http://bugs\.debian\.org/(\d+)\">(.*?): (.*?)</a>")

def get_installed_list():
    packages = []
    (sin, sout) = popen2("grep -B1 'Status: install ok installed' /var/lib/dpkg/status | grep Package | cut -f2 -d' '")

    for line in sin:
        packages.append(string.strip(line))

    return packages

def get_wnpp_list():
    packages = []
    url = urlopen('http://www.debian.org/devel/wnpp/orphaned')
    for line in url.readlines():
        m = wnpp_re.search(line)
        if m:
            packages.append({'bugnum': m.group(1),
                             'name': m.group(2),
                             'desc': m.group(3)})

    url = urlopen('http://www.debian.org/devel/wnpp/rfa_bypackage')
    for line in url.readlines():
        m = wnpp_re.search(line)
        if m:
            packages.append({'bugnum': m.group(1),
                             'name': m.group(2),
                             'desc': m.group(3)})

    return packages

def main():
    installed = get_installed_list()
    wnpp = get_wnpp_list()

    for p in wnpp:
        if p['name'] in installed:
            print "%6s %s: %s" % (p['bugnum'], p['name'], p['desc'])

if __name__ == '__main__':
    main()

Reply to: