From 72021b0a3b92a897145e98c3eec2fb9a97cbea87 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Tue, 29 Jul 2003 11:13:35 +0000 Subject: [PATCH] Handle parsing errors correctly. Don't consider redirections to be a fatal error -- we have have the wrong URL, but there's no sense in hammering the upstream site. --- rawdoglib/rawdog.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/rawdoglib/rawdog.py b/rawdoglib/rawdog.py index 8d6a4b6..a840548 100644 --- a/rawdoglib/rawdog.py +++ b/rawdoglib/rawdog.py @@ -60,21 +60,25 @@ class Feed: if not force and (now - self.last_update) < (self.period * 60): return 0 - error = None try: p = feedparser.parse(self.url, self.etag, self.modified, "rawdog/" + VERSION) + status = p.get("status") except: - error = "Error parsing feed." + p = None - status = p.get("status") - if status is None: + error = None + non_fatal = 0 + if p is None: + error = "Error parsing feed." + elif status is None: error = "Timeout while reading feed." elif status == 301: # Permanent redirect. The feed URL needs changing. error = "New URL: " + p["url"] + "\n" error += "The feed has moved permanently to a new URL.\n" error += "You should update its entry in your config file." + non_fatal = 1 elif status in [403, 410]: # The feed is disallowed or gone. The feed should be unsubscribed. error = "The feed has gone.\n" @@ -90,7 +94,8 @@ class Feed: print "HTTP Status: " + str(status) print error print - return 0 + if not non_fatal: + return 0 self.last_update = now -- 2.35.1