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

Generate list of educational packages using debtags, screenshots and UDD



Just to test if it could be done, I wrote a script to use UDD to list
the educational software in Debian, similar to the blog post I wrote a
while back, and pusted the result on
<URL: http://people.skolelinux.org/pere/edu-software-from-udd.html >.

I suspect we should set up some CGI script to generate this on the fly,
and use the summary in marketing.

The script, that can be executed on udd.debian.org (and possibly
alioth), look like this.

The SQL code is horrible, but it worked... :)


from psycopg2 import connect
from re import split, sub

query = """
SELECT package, tag from debtags
  WHERE tag like 'field::%'
    AND package IN (SELECT package FROM debtags
                      WHERE tag = 'use::learning'
                        AND package IN (SELECT package FROM debtags
                                         WHERE tag = 'role::program' and package in (select package from debtags where tag = 'interface::x11'))) order by tag, package;
"""

conn = connect(database='udd', port=5452, host='localhost', user='guest')
cur = conn.cursor()
cur.execute(query)
rows = cur.fetchall()
cur.close()
conn.close()

print """
<html>
<head>
<title>Debian Edu educational software</title>
</head>
<body>
<h1>Debian Edu educational software</h1>

<p>Packages tagged use::learning, role::program and interface::x11.</p>
"""

lastfieldtag = None
for row in rows:
    (package, fieldtag) = row
    if lastfieldtag != fieldtag:
        if lastfieldtag is not None:
            print "</p>"
        print "<strong>%s</strong>" % fieldtag
        print "<p>"
        lastfieldtag = fieldtag
    print "<a href=\"http://packages.debian.org/search?searchon=names&exact=1&suite=all&section=all&keywords=%s\";><img src=\"http://screenshots.debian.net/thumbnail/%s\";></a>" % (package, package)
if lastfieldtag is not None:
    print "</p>"

print """
</body>
</html>
"""

-- 
Happy hacking
Petter Reinholdtsen


Reply to: