import re
import sys
import time
-import encodings.ascii
from optparse import OptionParser
from datetime import datetime
import PyRSS2Gen
-from debian_bundle.deb822 import Changes
+from debian.deb822 import Changes
inrss_filename = "NEW_in.rss"
outrss_filename = "NEW_out.rss"
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:
try:
f = open(fname)
- except IOError, e:
+ except IOError as e:
sys.stderr.write("Can't open %s: %s\n" % (fname, e))
return {}
return False
description = "<pre>Description: %s\nChanges: %s\n</pre>" % \
- (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" % \
(msg['Source'], msg['Version'])
title,
pubDate = pubdate,
description = description,
- author = utf2ascii(cgi.escape(msg['Maintainer'])),
+ author = cgi.escape(msg['Maintainer']),
link = link,
guid = link
)
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)
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)
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)