Commit 6c796fce authored by Jelle van der Waa's avatar Jelle van der Waa 🚧
Browse files

planet: handle response without 'status'

feedparser's parse method returns an arbitrary dictionary which may or
may not have the HTTP status. Rely on get() to return None if it's
lacking and then return and log a message.
parent c41b3dac
......@@ -54,15 +54,19 @@ def parse_feed(self, feed_instance):
etag = cache.get(f'planet:etag:{url}')
feed = feedparser.parse(url, etag=etag)
http_status = feed.get('status')
if feed['status'] == 304:
if not http_status:"The feed '%s' returns no HTTP status", url)
if http_status == 304:"The feed '%s' has not changed since we last checked it", url)
if 'etag' in feed:
cache.set(f'planet:etag:{url}', feed.etag, 86400)
if feed['status'] != 200:"error parsing feed: '%s', status: '%s'", url, feed['status'])
if http_status != 200:"error parsing feed: '%s', status: '%s'", url, http_status)
if not feed.entries:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment