X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fwc.py;h=c8fd987813d866462211eef7c1209c8949ad9ecd;hb=e431d28492c1493db62650e5f55ebf74afddf79f;hp=d99eae60e1b04fcb319fd3653d64c7bc52981217;hpb=7e377bcff562d2adecf923e4871101e6f46a3a64;p=feedingit diff --git a/src/wc.py b/src/wc.py index d99eae6..c8fd987 100644 --- a/src/wc.py +++ b/src/wc.py @@ -40,11 +40,23 @@ except ImportError, exception: refresh_interval = 6 * 60 * 60 class mywoodchuck (PyWoodchuck): - def __init__(self, listing, *args): - PyWoodchuck.__init__ (self, *args) + def __init__(self, listing, human_readable_name, identifier, + request_feedback): + try: + PyWoodchuck.__init__ (self, human_readable_name, identifier, + request_feedback) + except Exception, 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)" @@ -65,11 +77,13 @@ class mywoodchuck (PyWoodchuck): stream.human_readable_name, stream.identifier)) _w = None -def wc_init(listing): +def wc_init(listing, request_feedback=False): + """Connect to the woodchuck server and initialize any state.""" global _w assert _w is None - _w = mywoodchuck (listing, "FeedingIt", "org.maemo.feedingit") + _w = mywoodchuck (listing, "FeedingIt", "org.marcoz.feedingit", + request_feedback) if not woodchuck_imported or not _w.available (): logger.info("Unable to contact Woodchuck server.") @@ -77,7 +91,7 @@ def wc_init(listing): 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