# HG changeset patch # User Goffi # Date 1453662366 -3600 # Node ID 0e9341e537d6d65b38cf66385566810abe23cf1d # Parent 7dde76708892dd5b3aba83ce4376ff5d1ac46fe1 server: catch exceptions on service profile connection check, and show an helping message if an error is caught diff -r 7dde76708892 -r 0e9341e537d6 src/server/server.py --- a/src/server/server.py Sun Jan 24 19:00:56 2016 +0100 +++ b/src/server/server.py Sun Jan 24 20:06:06 2016 +0100 @@ -1492,7 +1492,16 @@ self.stop() def initOk(dummy): - if not self.bridge.isConnected(C.SERVICE_PROFILE): + try: + connected = self.bridge.isConnected(C.SERVICE_PROFILE) + except Exception as e: + # we don't want the traceback + msg = [l for l in unicode(e).split('\n') if l][-1] + log.error(u"Can't check service profile ({profile}), are you sure it exists ?\n{error}".format( + profile=C.SERVICE_PROFILE, error=msg)) + self.stop() + return + if not connected: self.bridge.asyncConnect(C.SERVICE_PROFILE, self.options['passphrase'], callback=self._startService, errback=eb) else: @@ -1608,7 +1617,10 @@ log.info(_("launching cleaning methods")) for callback, args, kwargs in self._cleanup: callback(*args, **kwargs) - self.bridge.disconnect(C.SERVICE_PROFILE) + try: + self.bridge.disconnect(C.SERVICE_PROFILE) + except Exception: + log.warning(u"Can't disconnect service profile") def run(self): reactor.run()