def _handle_app_cast(data, up_to_date_callback): """Handle appcast data when it's correctly fetched """ try: appcast = feedparser.parse(data['body']) if appcast['bozo'] == '1': return up_to_date = True latest = _get_item_for_latest(appcast) if latest is None: logging.info('No updates for this platform.') # this will go through the finally clause below return serial = int(app.config.get(prefs.APP_SERIAL)) up_to_date = (serial >= _get_item_serial(latest)) if not up_to_date: logging.info('New update available.') signals.system.update_available(latest) elif up_to_date_callback: logging.info('Up to date. Notifying callback.') up_to_date_callback() else: logging.info('Up to date.') except (SystemExit, KeyboardInterrupt): raise except: logging.exception("Error while handling appcast data.") finally: global check_in_progress check_in_progress = False eventloop.add_timeout(86400, check_for_updates, "Check for updates")
def setUp(self): FeedTestCase.setUp(self) self.tempdb = os.path.join(self.tempdir, 'democracy-temp-db') if os.path.exists(self.tempdb): os.remove(self.tempdb) self.reload_database(self.tempdb) self.write_feed() self.parsed_feed = feedparser.parse(self.filename) self.make_feed() self.save_then_restore_db()
def parse(url_file_stream_or_string): """Parse a feed. This method runs the feed data through feedparser.parse, then does some other things like unicodify it and fix issues with certain feed providers. """ parsed = feedparser.parse(url_file_stream_or_string) parsed = util.unicodify(parsed) _yahoo_hack(parsed['entries']) return parsed
def force_feed_parser_callback(self, my_feed): # a hack to get the feed to update without eventloop feedimpl = my_feed.actualFeed feedimpl.feedparser_callback(feedparser.parse(feedimpl.initialHTML))
def parse(url_file_stream_or_string): return feedparser.parse(url_file_stream_or_string, USER_AGENT)
def test_usvideo(self): # test for bug 10653 d = feedparser.parse(os.path.join(FEEDPARSERTESTS, "usvideo.xml")) # this should kick up a KeyError and NOT a TypeError self.assertRaises(KeyError, lambda: d['url'])
def test_ooze(self): feedparser.parse(os.path.join(FEEDPARSERTESTS, "ooze.rss"))