コード例 #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")
コード例 #2
0
ファイル: autoupdate.py プロジェクト: codito/miro
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")
コード例 #3
0
ファイル: feedtest.py プロジェクト: zjmmjzzjm/miro
 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()
コード例 #4
0
ファイル: feedtest.py プロジェクト: CodeforEvolution/miro
 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()
コード例 #5
0
ファイル: feedparsertest.py プロジェクト: zjmmjzzjm/miro
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
コード例 #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
コード例 #7
0
ファイル: workerprocess.py プロジェクト: adarshr/miro
 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
コード例 #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
コード例 #9
0
ファイル: feedparsertest.py プロジェクト: zjmmjzzjm/miro
    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'])
コード例 #10
0
ファイル: feedparsertest.py プロジェクト: zjmmjzzjm/miro
 def test_ooze(self):
     feedparserutil.parse(os.path.join(FPTESTINPUT, "ooze.rss"))
コード例 #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'])
コード例 #12
0
 def test_ooze(self):
     feedparserutil.parse(os.path.join(FPTESTINPUT, "ooze.rss"))
コード例 #13
0
ファイル: unicodetest.py プロジェクト: kmshi/miro
 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))
コード例 #14
0
ファイル: unicodetest.py プロジェクト: ShriramK/miro
 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))