command: In run(), save feeds even after errors
authorW. Trevor King <wking@tremily.us>
Wed, 13 Feb 2013 14:12:05 +0000 (09:12 -0500)
committerW. Trevor King <wking@tremily.us>
Wed, 13 Feb 2013 15:01:38 +0000 (10:01 -0500)
It's annoying to have a few feeds processed successfully and then have
one feed with a configuration error take down the process without
saving.  With this commit, we always safe the feeds, regardless of any
error.  We also catch and log any RSS2EmailError, not just the
NoToEmailAddress and ProcessingErrors we caught earlier.

Signed-off-by: W. Trevor King <wking@tremily.us>
rss2email/command.py

index d404155c8849ccca2ae922bba1fa78d447fb606c..8d8fc82e5683450acef014286f4832f1385387c4 100644 (file)
@@ -53,16 +53,16 @@ def run(feeds, args):
     "Fetch feeds and send entry emails."
     if not args.index:
         args.index = range(len(feeds))
-    for index in args.index:
-        feed = feeds.index(index)
-        if feed.active:
-            try:
-                feed.run(send=args.send)
-            except _error.NoToEmailAddress as e:
-                e.log()
-            except _error.ProcessingError as e:
-                e.log()
-    feeds.save()
+    try:
+        for index in args.index:
+            feed = feeds.index(index)
+            if feed.active:
+                try:
+                    feed.run(send=args.send)
+                except _error.RSS2EmailError as e:
+                    e.log()
+    finally:
+        feeds.save()
 
 def list(feeds, args):
     "List all the feeds in the database"