Example #1
0
def _handle_app_cast(data, up_to_date_callback):
    """Handle appcast data when it's correctly fetched
    """
    try:
        appcast = feedparserutil.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 StandardError:
        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")
Example #2
0
def _handle_app_cast(data, up_to_date_callback):
    """Handle appcast data when it's correctly fetched
    """
    try:
        appcast = feedparserutil.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 StandardError:
        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")
Example #3
0
 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 = feedparserutil.parse(self.filename)
     self.make_feed()
     self.save_then_restore_db()
Example #4
0
 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 = feedparserutil.parse(self.filename)
     self.make_feed()
     self.save_then_restore_db()
Example #5
0
def _parse_feed(inputfile):
    """Runs feedparserutil.parse on the inputfile and returns a dict
    of feedparser stuff.

    :param inputfile: the name of the input file in the FPTESTINPUT
        directory.

    :returns: the feedparser dict

    :raises AssertionError: if the feedparser has problems and the
        feedparser dict has 'bozo_exception' in it.
    """
    fn = os.path.join(FPTESTINPUT, inputfile)
    d = feedparserutil.parse(fn)
    assert (not d["bozo"] or "entries" in d), ("Feed didn't parse: %s %s" %
                                               (fn, d["bozo_exception"]))
    return d
Example #6
0
def _parse_feed(inputfile):
    """Runs feedparserutil.parse on the inputfile and returns a dict
    of feedparser stuff.

    :param inputfile: the name of the input file in the FPTESTINPUT
        directory.

    :returns: the feedparser dict

    :raises AssertionError: if the feedparser has problems and the
        feedparser dict has 'bozo_exception' in it.
    """
    fn = os.path.join(FPTESTINPUT, inputfile)
    d = feedparserutil.parse(fn)
    assert (not d["bozo"] or "entries" in d), ("Feed didn't parse: %s %s" %
                                               (fn, d["bozo_exception"]))
    return d
Example #7
0
 def handle_feedparser_task(self, msg):
     parsed_feed = feedparserutil.parse(msg.html)
     # bozo_exception is sometimes C object that is not picklable.  We
     # don't use it anyways, so just unset the value
     parsed_feed['bozo_exception'] = None
     return parsed_feed
Example #8
0
 def handle_feedparser_task(self, msg):
     parsed_feed = feedparserutil.parse(msg.html)
     # bozo_exception is sometimes C object that is not picklable.  We
     # don't use it anyways, so just unset the value
     parsed_feed['bozo_exception'] = None
     return parsed_feed
Example #9
0
    def test_usvideo(self):
        # test for bug 10653
        d = feedparserutil.parse(os.path.join(FPTESTINPUT, "usvideo.xml"))

        # this should kick up a KeyError and NOT a TypeError
        self.assertRaises(KeyError, lambda: d['url'])
Example #10
0
 def test_ooze(self):
     feedparserutil.parse(os.path.join(FPTESTINPUT, "ooze.rss"))
Example #11
0
    def test_usvideo(self):
        # test for bug 10653
        d = feedparserutil.parse(os.path.join(FPTESTINPUT, "usvideo.xml"))

        # this should kick up a KeyError and NOT a TypeError
        self.assertRaises(KeyError, lambda: d['url'])
Example #12
0
 def test_ooze(self):
     feedparserutil.parse(os.path.join(FPTESTINPUT, "ooze.rss"))
Example #13
0
 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(feedparserutil.parse(
         feedimpl.initialHTML))
Example #14
0
 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(
         feedparserutil.parse(feedimpl.initialHTML))