From: Neal H. Walfield Date: Tue, 6 Sep 2011 20:54:06 +0000 (+0200) Subject: If initializing the Woodchuck connection fails, just disable Woodchuck. X-Git-Url: https://vcs.maemo.org/git/?p=feedingit;a=commitdiff_plain;h=748ecab622060beac8dcebe22bd2e56ba4310b5c If initializing the Woodchuck connection fails, just disable Woodchuck. --- diff --git a/src/wc.py b/src/wc.py index cb73c47..b061138 100644 --- a/src/wc.py +++ b/src/wc.py @@ -42,11 +42,21 @@ refresh_interval = 6 * 60 * 60 class mywoodchuck (PyWoodchuck): def __init__(self, listing, human_readable_name, identifier, request_feedback): - PyWoodchuck.__init__ (self, human_readable_name, identifier, - request_feedback) + try: + PyWoodchuck.__init__ (self, human_readable_name, identifier, + request_feedback) + except woodchuck.Error, e: + logger.error( + "Failed to establish a connection to the Woodchuck server: %s" + % (str(e),)) + self.available = self.not_available + return self.listing = listing + def not_available(self): + return False + # Woodchuck upcalls. def stream_update_cb(self, stream): logger.debug("stream update called on %s (%s)" @@ -68,6 +78,7 @@ class mywoodchuck (PyWoodchuck): _w = None def wc_init(listing, request_feedback=False): + """Connect to the woodchuck server and initialize any state.""" global _w assert _w is None @@ -80,7 +91,7 @@ def wc_init(listing, request_feedback=False): logger.debug("Woodchuck appears to be available.") def wc(): - """Connect to the woodchuck server and initialize any state.""" + """Return the Woodchuck singleton.""" global _w assert _w is not None return _w