changeset 244:b46d7fe6390b

re-activate the use of proxy
author Dirk Olmes <dirk@xanthippe.ping.de>
date Tue, 09 Jun 2015 02:19:00 +0200
parents 51d2c3d55f4b
children 8e73a8ae863f
files backend/AbstractFeedUpdater.py
diffstat 1 files changed, 12 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/backend/AbstractFeedUpdater.py	Mon Jun 08 19:27:35 2015 +0200
+++ b/backend/AbstractFeedUpdater.py	Tue Jun 09 02:19:00 2015 +0200
@@ -25,18 +25,21 @@
         self._processEntries(result)
 
     def _retrieveFeed(self):
-        # Retrieving https connections over a proxy does not seem to work currently
-        #if self.preferences.isProxyConfigured():
-        #    proxyUrl = '{0}:{1}'.format(self.preferences.proxyHost(), self.preferences.proxyPort())
-        #    proxyHandler = ProxyHandler({'http': proxyUrl, 'https': proxyUrl})
-        #    result = feedparser.parse(self.feed.rss_url, handlers=[proxyHandler])
-        #else:
-        #    # when updating to python3 see http://code.google.com/p/feedparser/issues/detail?id=260
-        result = feedparser.parse(self.feed.rss_url)
+        # when updating to python3 see http://code.google.com/p/feedparser/issues/detail?id=260
+        handlers = None
+        if self.preferences.isProxyConfigured() and self.preferences.useProxy():
+            proxyUrl = '{0}:{1}'.format(self.preferences.proxyHost(), self.preferences.proxyPort())
+            proxyHandler = ProxyHandler({'http': proxyUrl, 'https': proxyUrl})
+            handlers = [proxyHandler]
+
+        result = feedparser.parse(self.feed.rss_url, handlers)
+        if result.bozo > 0:
+            log.warn('result contains bozo')
+            log.warn(result)
         # bozo flags if a feed is well-formed.
 #        if result["bozo"] > 0:
 #            raise FeedUpdateException()
-        status = result["status"]
+        status = result.status
         if status >= STATUS_ERROR:
             raise FeedUpdateException("HTTP status " + str(status))
         return result