Add some more comprehensive tests for the changeconfig option; in
particular, test it more thoroughly with splitstate both on and off.
+Don't crash if feedparser raises an exception during an update (i.e.
+assume that any part of feedparser's response might be missing, until
+we've checked that there wasn't an exception).
+
- rawdog 2.18
Be consistent about catching AttributeError when looking for attributes
# rawdog: RSS aggregator without delusions of grandeur.
-# Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Adam Sampson <ats@offog.org>
+# Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013, 2014 Adam Sampson <ats@offog.org>
#
# rawdog is free software; you can redistribute and/or modify it
# under the terms of that license as published by the Free Software
"""Add new articles from a feed to the collection.
Returns True if any articles were read, False otherwise."""
+ # Note that feedparser might have thrown an exception --
+ # so until we print the error message and return, we
+ # can't assume that p contains any particular field.
+
responses = p.get("rawdog_responses")
if len(responses) > 0:
last_status = responses[-1]["status"]
- elif len(p["feed"]) != 0:
+ elif len(p.get("feed", [])) != 0:
# Some protocol other than HTTP -- assume it's OK,
# since we got some content.
last_status = 200
errors.append("If this condition persists, you should remove it from your config file.")
errors.append("")
fatal = True
- elif version == "" and len(p["entries"]) == 0:
+ elif version == "" and len(p.get("entries", [])) == 0:
# feedparser couldn't detect the type of this feed or
# retrieve any entries from it.
errors.append("The data retrieved from this URL could not be understood as a feed.")
if fatal:
return False
+ # From here, we can assume that we've got a complete feedparser
+ # response.
+
p = ensure_unicode(p, p.get("encoding") or "UTF-8")
# No entries means the feed hasn't changed, but for some reason
done
done
+begin "exception raised by feedparser"
+make_rss20 $statedir/feed.rss
+add "feed 0 feed.rss"
+cat >$statedir/plugins/crash.py <<EOF
+import feedparser
+def crash(*args, **kwargs):
+ raise Exception("exception from feedparser")
+feedparser.parse = crash
+EOF
+rune "Error fetching or parsing feed" -u
+contains $outfile "exception from feedparser"
+
begin "with --no-locking"
make_rss20 $statedir/simple.rss
add "splitstate true"