From: Adam Sampson Date: Tue, 29 Jul 2003 07:10:18 +0000 (+0000) Subject: Add correct handling of HTTP status codes, to pass tests on X-Git-Tag: v1.2~9 X-Git-Url: http://git.ozo.com/?a=commitdiff_plain;h=4828fcbe0db7b75b40c266a95f75335cf64d14e7;p=rawdog%2F.git Add correct handling of HTTP status codes, to pass tests on . --- diff --git a/rawdoglib/rawdog.py b/rawdoglib/rawdog.py index ffd0a3f..d614d15 100644 --- a/rawdoglib/rawdog.py +++ b/rawdoglib/rawdog.py @@ -65,9 +65,33 @@ class Feed: p = feedparser.parse(self.url, self.etag, self.modified, "rawdog/" + VERSION) except: - print "Error fetching " + self.url + print "Feed: " + self.url + print "Error parsing feed." + print return 0 + status = p["status"] + message = None + if status == 301: + # Permanent redirect. The feed URL needs changing. + message = "New URL: " + p["url"] + "\n" + message += "The feed has moved permanently to a new URL.\n" + message += "You should update its entry in your config file." + elif status in [403, 410]: + # The feed is disallowed or gone. The feed should be unsubscribed. + message = "The feed has gone.\n" + message += "You should remove it from your config file." + elif status / 100 in [4, 5]: + # Some sort of client or server error. The feed may need unsubscribing. + message = "The feed returned an error.\n" + message += "If this condition persists, you should remove it from your config file." + + if message is not None: + print "Feed: " + self.url + print "HTTP Status: " + str(status) + print message + print + self.etag = p.get("etag") self.modified = p.get("modified") # In the event that the feed hasn't changed, then both channel