Example #1
0
    def update_feed(self, feed):
        handlers = []
        if utils.web.proxy():
            handlers.append(
                ProxyHandler({'http': utils.force(utils.web.proxy())}))
            handlers.append(
                ProxyHandler({'https': utils.force(utils.web.proxy())}))
        with feed.lock:
            d = feedparser.parse(feed.url,
                                 etag=feed.etag,
                                 modified=feed.modified,
                                 handlers=handlers)
            if 'status' not in d or d.status != 304:  # Not modified
                if 'etag' in d:
                    feed.etag = d.etag
                if 'modified' in d:
                    feed.modified = d.modified
                feed.data = d.feed
                feed.entries = d.entries
                feed.last_update = time.time()
                # feedparser will store soft errors in bozo_exception and set
                # the "bozo" bit to 1 on supported platforms:
                # https://pythonhosted.org/feedparser/bozo.html
                # If this error caused us to e.g. not get any entries at all,
                # it may be helpful to show it as well.
                if getattr(d, 'bozo', 0) and hasattr(d, 'bozo_exception'):
                    feed.last_exception = d.bozo_exception
                else:
                    feed.last_exception = None

            (initial, feed.initial) = (feed.initial, False)
        self.announce_feed(feed, initial)
Example #2
0
    def update_feed(self, feed):
        handlers = []
        if utils.web.proxy():
            handlers.append(ProxyHandler(
                {'http': utils.force(utils.web.proxy())}))
            handlers.append(ProxyHandler(
                {'https': utils.force(utils.web.proxy())}))
        with feed.lock:
            d = feedparser.parse(feed.url, etag=feed.etag,
                    modified=feed.modified, handlers=handlers)
            if 'status' not in d or d.status != 304: # Not modified
                if 'etag' in d:
                    feed.etag = d.etag
                if 'modified' in d:
                    feed.modified = d.modified
                feed.data = d.feed
                feed.entries = d.entries
                feed.last_update = time.time()
                # feedparser will store soft errors in bozo_exception and set
                # the "bozo" bit to 1 on supported platforms:
                # https://pythonhosted.org/feedparser/bozo.html
                # If this error caused us to e.g. not get any entries at all,
                # it may be helpful to show it as well.
                if getattr(d, 'bozo', 0) and hasattr(d, 'bozo_exception'):
                    feed.last_exception = d.bozo_exception
                else:
                    feed.last_exception = None

            (initial, feed.initial) = (feed.initial, False)
        self.announce_feed(feed, initial)
Example #3
0
 def update_feed(self, feed):
     handlers = []
     if utils.web.proxy():
         handlers.append(ProxyHandler({"http": utils.force(utils.web.proxy())}))
         handlers.append(ProxyHandler({"https": utils.force(utils.web.proxy())}))
     with feed.lock:
         d = feedparser.parse(feed.url, etag=feed.etag, modified=feed.modified, handlers=handlers)
         if "status" not in d or d.status != 304:  # Not modified
             if "etag" in d:
                 feed.etag = d.etag
             if "modified" in d:
                 feed.modified = d.modified
             feed.data = d.feed
             feed.entries = d.entries
             feed.last_update = time.time()
         (initial, feed.initial) = (feed.initial, False)
     self.announce_feed(feed, initial)
Example #4
0
 def update_feed(self, feed):
     handlers = []
     if utils.web.proxy():
         handlers.append(ProxyHandler(
             {'http': utils.force(utils.web.proxy())}))
         handlers.append(ProxyHandler(
             {'https': utils.force(utils.web.proxy())}))
     with feed.lock:
         d = feedparser.parse(feed.url, etag=feed.etag,
                 modified=feed.modified, handlers=handlers)
         if 'status' not in d or d.status != 304: # Not modified
             if 'etag' in d:
                 feed.etag = d.etag
             if 'modified' in d:
                 feed.modified = d.modified
             feed.data = d.feed
             feed.entries = d.entries
             feed.last_update = time.time()
         (initial, feed.initial) = (feed.initial, False)
     self.announce_feed(feed, initial)