From e1befe89e1355b6ca19f720f67f7503a79daeaee Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Sat, 18 Oct 2008 10:14:25 +0000 Subject: [PATCH] Exception handling for semi-broken RSS feeds, like those at Sun... --- discovery.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/discovery.py b/discovery.py index 689a708..3ec675d 100755 --- a/discovery.py +++ b/discovery.py @@ -33,11 +33,15 @@ class Aggregator: # not ok! print "Feed %s status %s" % (feedinfo[1], feed.status) return - - if feed.feed.link: - print "Setting feed for %s to %s" % (feedinfo[2], feed.feed.link) - c = self.db.cursor() - c.execute("UPDATE planet.feeds SET blogurl='%s' WHERE id=%i" % (feed.feed.link, feedinfo[0])) + + try: + if feed.feed.link: + print "Setting feed for %s to %s" % (feedinfo[2], feed.feed.link) + c = self.db.cursor() + c.execute("UPDATE planet.feeds SET blogurl='%s' WHERE id=%i" % (feed.feed.link, feedinfo[0])) + except: + print "Exception when processing feed for %s" % (feedinfo[2]) + print feed if __name__=="__main__": Aggregator(psycopg2.connect('dbname=planetpg host=/tmp/')).Update() -- 2.39.5