comparison backend/AbstractFeedUpdater.py @ 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
comparison
equal deleted inserted replaced
243:51d2c3d55f4b 244:b46d7fe6390b
23 result = self._retrieveFeed() 23 result = self._retrieveFeed()
24 self._setFeedTitle(result) 24 self._setFeedTitle(result)
25 self._processEntries(result) 25 self._processEntries(result)
26 26
27 def _retrieveFeed(self): 27 def _retrieveFeed(self):
28 # Retrieving https connections over a proxy does not seem to work currently 28 # when updating to python3 see http://code.google.com/p/feedparser/issues/detail?id=260
29 #if self.preferences.isProxyConfigured(): 29 handlers = None
30 # proxyUrl = '{0}:{1}'.format(self.preferences.proxyHost(), self.preferences.proxyPort()) 30 if self.preferences.isProxyConfigured() and self.preferences.useProxy():
31 # proxyHandler = ProxyHandler({'http': proxyUrl, 'https': proxyUrl}) 31 proxyUrl = '{0}:{1}'.format(self.preferences.proxyHost(), self.preferences.proxyPort())
32 # result = feedparser.parse(self.feed.rss_url, handlers=[proxyHandler]) 32 proxyHandler = ProxyHandler({'http': proxyUrl, 'https': proxyUrl})
33 #else: 33 handlers = [proxyHandler]
34 # # when updating to python3 see http://code.google.com/p/feedparser/issues/detail?id=260 34
35 result = feedparser.parse(self.feed.rss_url) 35 result = feedparser.parse(self.feed.rss_url, handlers)
36 if result.bozo > 0:
37 log.warn('result contains bozo')
38 log.warn(result)
36 # bozo flags if a feed is well-formed. 39 # bozo flags if a feed is well-formed.
37 # if result["bozo"] > 0: 40 # if result["bozo"] > 0:
38 # raise FeedUpdateException() 41 # raise FeedUpdateException()
39 status = result["status"] 42 status = result.status
40 if status >= STATUS_ERROR: 43 if status >= STATUS_ERROR:
41 raise FeedUpdateException("HTTP status " + str(status)) 44 raise FeedUpdateException("HTTP status " + str(status))
42 return result 45 return result
43 46
44 def _processEntries(self, feedDict): 47 def _processEntries(self, feedDict):