X-Git-Url: https://git.decadent.org.uk/gitweb/?p=dak.git;a=blobdiff_plain;f=tools%2Fqueue_rss.py;h=fd49c0dfe1f0173a7c0fd343e7ed37a1af5cd9bc;hp=8eb81f17da99df7b755e3e7209531c99293a3936;hb=HEAD;hpb=05c4968c640f85551908ba3ef0bf8c9cecfea463 diff --git a/tools/queue_rss.py b/tools/queue_rss.py index 8eb81f17..fd49c0df 100755 --- a/tools/queue_rss.py +++ b/tools/queue_rss.py @@ -12,13 +12,13 @@ import cPickle import re import sys import time -import encodings.ascii from optparse import OptionParser from datetime import datetime +from email.utils import parseaddr import PyRSS2Gen -from debian_bundle.deb822 import Changes +from debian.deb822 import Changes inrss_filename = "NEW_in.rss" outrss_filename = "NEW_out.rss" @@ -43,24 +43,16 @@ class Status: def __init__(self): self.feed_in = PyRSS2Gen.RSS2( title = "Packages entering NEW", - link = "http://ftp-master.debian.org/new.html", + link = "https://ftp-master.debian.org/new.html", description = "Debian packages entering the NEW queue" ) self.feed_out = PyRSS2Gen.RSS2( title = "Packages leaving NEW", - link = "http://ftp-master.debian.org/new.html", + link = "https://ftp-master.debian.org/new.html", description = "Debian packages leaving the NEW queue" ) self.queue = {} -def utf2ascii(src): - """ Return an ASCII encoded copy of the input UTF-8 string """ - try: - res = unicode(src, 'utf-8').encode('ascii', 'replace') - except UnicodeDecodeError: - res = None - return res - def purge_old_items(feed, max): """ Purge RSSItem from feed, no more than max. """ if feed.items is None or len(feed.items) == 0: @@ -112,7 +104,7 @@ def parse_leave_reason(fname): try: f = open(fname) - except IOError, e: + except IOError as e: sys.stderr.write("Can't open %s: %s\n" % (fname, e)) return {} @@ -144,18 +136,21 @@ def add_rss_item(status, msg, direction): return False description = "
Description: %s\nChanges: %s\n
" % \ - (utf2ascii(cgi.escape(msg['Description'])), - utf2ascii(cgi.escape(msg['Changes']))) + (cgi.escape(msg['Description']), + cgi.escape(msg['Changes'])) - link = "http://ftp-master.debian.org/new/%s_%s.html" % \ + link = "https://ftp-master.debian.org/new/%s_%s.html" % \ (msg['Source'], msg['Version']) + maintainer = parseaddr(msg['Maintainer']) + author = "%s (%s)" % (maintainer[1], maintainer[0]) + feed.items.insert(0, PyRSS2Gen.RSSItem( title, pubDate = pubdate, description = description, - author = utf2ascii(cgi.escape(msg['Maintainer'])), + author = cgi.escape(author), link = link, guid = link ) @@ -207,10 +202,6 @@ if __name__ == "__main__": status = Status() current_queue = parse_queuedir(settings.queuedir) - if not current_queue: - sys.stderr.write("Unable to scan queuedir '%s'\n" % settings.queuedir) - parser.print_help() - sys.exit(1) update_feeds(current_queue, status, settings) @@ -223,7 +214,7 @@ if __name__ == "__main__": try: status.feed_in.write_xml(file(feed_in_file, "w+"), "utf-8") status.feed_out.write_xml(file(feed_out_file, "w+"), "utf-8") - except IOError, why: + except IOError as why: sys.stderr.write("Unable to write feeds: %s\n", why) sys.exit(1) @@ -231,7 +222,7 @@ if __name__ == "__main__": try: cPickle.dump(status, open(status_db, "w+")) - except IOError, why: + except IOError as why: sys.stderr.write("Unable to save status: %s\n", why) sys.exit(1)