From: Neal H. Walfield Date: Thu, 20 Oct 2011 19:49:59 +0000 (+0200) Subject: If Woodchuck initialization fails, handle the error gracefully. X-Git-Url: http://git.maemo.org/git/?p=feedingit;a=commitdiff_plain;h=a46f20efe3d8b2ba4125f07bd82e35d3e4311fa5 If Woodchuck initialization fails, handle the error gracefully. --- diff --git a/src/rss_sqlite.py b/src/rss_sqlite.py index a1f5d2d..4b4d276 100644 --- a/src/rss_sqlite.py +++ b/src/rss_sqlite.py @@ -972,36 +972,39 @@ class Listing(BaseObject): # Check that Woodchuck's state is up to date with respect our # state. - updater = os.path.basename(sys.argv[0]) == 'update_feeds.py' - wc_init (self, True if updater else False) - if wc().available() and updater: - # The list of known streams. - streams = wc().streams_list () - stream_ids = [s.identifier for s in streams] - - # Register any unknown streams. Remove known streams from - # STREAMS_IDS. - for key in self.getListOfFeeds(): - title = self.getFeedTitle(key) - # XXX: We should also check whether the list of - # articles/objects in each feed/stream is up to date. - if key not in stream_ids: - logger.debug( - "Registering previously unknown channel: %s (%s)" - % (key, title,)) - # Use a default refresh interval of 6 hours. - wc().stream_register (key, title, 6 * 60 * 60) - else: - # Make sure the human readable name is up to date. - if wc()[key].human_readable_name != title: - wc()[key].human_readable_name = title - stream_ids.remove (key) - - - # Unregister any streams that are no longer subscribed to. - for id in stream_ids: - logger.debug("Unregistering %s" % (id,)) - w.stream_unregister (id) + try: + updater = os.path.basename(sys.argv[0]) == 'update_feeds.py' + wc_init (self, True if updater else False) + if wc().available() and updater: + # The list of known streams. + streams = wc().streams_list () + stream_ids = [s.identifier for s in streams] + + # Register any unknown streams. Remove known streams from + # STREAMS_IDS. + for key in self.getListOfFeeds(): + title = self.getFeedTitle(key) + # XXX: We should also check whether the list of + # articles/objects in each feed/stream is up to date. + if key not in stream_ids: + logger.debug( + "Registering previously unknown channel: %s (%s)" + % (key, title,)) + # Use a default refresh interval of 6 hours. + wc().stream_register (key, title, 6 * 60 * 60) + else: + # Make sure the human readable name is up to date. + if wc()[key].human_readable_name != title: + wc()[key].human_readable_name = title + stream_ids.remove (key) + + + # Unregister any streams that are no longer subscribed to. + for id in stream_ids: + logger.debug("Unregistering %s" % (id,)) + w.stream_unregister (id) + except Exception: + logger.exception("Registering streams with Woodchuck") def importOldFormatFeeds(self): """This function loads feeds that are saved in an outdated format, and converts them to sqlite"""