Exception handling for semi-broken RSS feeds, like those at Sun...
authorMagnus Hagander <magnus@hagander.net>
Sat, 18 Oct 2008 10:14:25 +0000 (10:14 +0000)
committerMagnus Hagander <magnus@hagander.net>
Sat, 18 Oct 2008 10:14:25 +0000 (10:14 +0000)
discovery.py

index 689a70844c70977d5466bd34304b64c2d7bd74c1..3ec675d891aa77bca9229ea00789d792c48449a2 100755 (executable)
@@ -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()