From f5b166d33223334eb6dc5d878691626f7bc2e9e1 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Tue, 28 Feb 2017 19:09:02 +0000 Subject: [PATCH] Fix the error message when a redirect-edit fails. This has been broken since 2.15 ("Make it possible to report more than one error at once."); I'd forgotten that change_feed_url also prints messages when adding the "errors" code. --- NEWS | 4 ++++ rawdoglib/rawdog.py | 11 +++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 0223e96..044c092 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,9 @@ - rawdog 2.23 +When automatically updating the config file in response to an HTTP +redirect fails, produce a more sensible error message (including the URL +of the feed in question). + - rawdog 2.22 When handling an HTTP 301 redirect response, check whether the new diff --git a/rawdoglib/rawdog.py b/rawdoglib/rawdog.py index a5e6bfe..64ae93f 100644 --- a/rawdoglib/rawdog.py +++ b/rawdoglib/rawdog.py @@ -562,8 +562,7 @@ class Feed: errors.append("New URL: " + location) errors.append("The feed has moved permanently to a new URL.") if config["changeconfig"]: - rawdog.change_feed_url(self.url, location, config) - errors.append("The config file has been updated automatically.") + rawdog.change_feed_url(self.url, location, config, errors.append) else: errors.append("You should update its entry in your config file.") errors.append("") @@ -1262,13 +1261,13 @@ class Rawdog(Persistable): version = 1 return version == STATE_VERSION - def change_feed_url(self, oldurl, newurl, config): + def change_feed_url(self, oldurl, newurl, config, error_fn): """Change the URL of a feed.""" assert self.feeds.has_key(oldurl) if self.feeds.has_key(newurl): - print >>sys.stderr, "Error: New feed URL is already subscribed; please remove the old one" - print >>sys.stderr, "from the config file by hand." + error_fn("Error: New feed URL is already subscribed; please remove the old one") + error_fn("from the config file by hand.") return edit_file("config", ChangeFeedEditor(oldurl, newurl).edit) @@ -1293,7 +1292,7 @@ class Rawdog(Persistable): if article.feed == oldurl: article.feed = newurl - print >>sys.stderr, "Feed URL automatically changed." + error_fn("The config file has been updated automatically.") def list(self, config): """List the configured feeds.""" -- 2.35.1