[Tails-dev] iceweasel backports upload notifications

Borrar esta mensaxe

Responder a esta mensaxe
Autor: bertagaz
Data:  
Para: tails-dev
Asunto: [Tails-dev] iceweasel backports upload notifications
Hi,

Here's a little python script I've installed on my account on
alioth.debian.org.

It send an email to whoever is in the "RM" dict (which should be the
current Tails Release Managers) when the UDD [1] is aware that a new
iceweasel backport for squeeze has been uploaded in Debian. It is run once
every hours by a cronjob.

It is pretty basic and crappy, but might give an idea how to play with
this database. I dunno how often the datas in there are refreshed with the
rest of the Debian infrastructure, so we'll see if it is useful.

So release managers, prepare yourself to receive an email! :D

[1] Ultimate Debian Database : http://udd.debian.org or
    http://wiki.debian.org/UltimateDebianDatabase

#!/usr/bin/env python

import psycopg2
import smtplib
from email.mime.text import MIMEText

RM = ["ague@???", "intrigeri@???", "anonym@???"]
CACHE_FILE="/srv/home/users/bertagaz-guest/.cache/check_iceweasel_uploads"

def get_last_version(c):
    c.execute("SELECT version from all_packages where package='iceweasel' and release='squeeze-backports' order by version limit 1")
    return c.fetchall()[0][0]


def send_new_upload_email(last_seen, new):
    msg = MIMEText("A new version of iceweasel has been uploaded to squeeze-backports :\n\n Previous : %s\n New : %s" % (last_seen, new))
    msg['Subject'] = ('New iceweasel upload in squeeze-backports : %s.' % new)
    msg['From'] = "bertagaz-guest@???"
    s = smtplib.SMTP()
    s.connect('localhost')
    s.sendmail("bertagaz-guest@???", RM, msg.as_string())
    s.quit()



if __name__ == '__main__':
    f = open(CACHE_FILE, "r")
    last_seen = f.read()
    f.closed
    conn = psycopg2.connect(host="udd.debian.org",port=5452,user="guest",database="udd")
    c = conn.cursor()
    new = get_last_version(c)
    if new > last_seen:
        send_new_upload_email(last_seen, new)
        f = open(CACHE_FILE, "w")
        f.write(new)
        f.closed