Mercurial > libervia-web
comparison src/server/server.py @ 859:0e9341e537d6
server: catch exceptions on service profile connection check, and show an helping message if an error is caught
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 24 Jan 2016 20:06:06 +0100 |
parents | 7dde76708892 |
children | e3e2effc9a4c |
comparison
equal
deleted
inserted
replaced
858:7dde76708892 | 859:0e9341e537d6 |
---|---|
1490 def eb(e): | 1490 def eb(e): |
1491 log.error(_(u"Connection failed: %s") % e) | 1491 log.error(_(u"Connection failed: %s") % e) |
1492 self.stop() | 1492 self.stop() |
1493 | 1493 |
1494 def initOk(dummy): | 1494 def initOk(dummy): |
1495 if not self.bridge.isConnected(C.SERVICE_PROFILE): | 1495 try: |
1496 connected = self.bridge.isConnected(C.SERVICE_PROFILE) | |
1497 except Exception as e: | |
1498 # we don't want the traceback | |
1499 msg = [l for l in unicode(e).split('\n') if l][-1] | |
1500 log.error(u"Can't check service profile ({profile}), are you sure it exists ?\n{error}".format( | |
1501 profile=C.SERVICE_PROFILE, error=msg)) | |
1502 self.stop() | |
1503 return | |
1504 if not connected: | |
1496 self.bridge.asyncConnect(C.SERVICE_PROFILE, self.options['passphrase'], | 1505 self.bridge.asyncConnect(C.SERVICE_PROFILE, self.options['passphrase'], |
1497 callback=self._startService, errback=eb) | 1506 callback=self._startService, errback=eb) |
1498 else: | 1507 else: |
1499 self._startService() | 1508 self._startService() |
1500 | 1509 |
1606 | 1615 |
1607 def stopService(self): | 1616 def stopService(self): |
1608 log.info(_("launching cleaning methods")) | 1617 log.info(_("launching cleaning methods")) |
1609 for callback, args, kwargs in self._cleanup: | 1618 for callback, args, kwargs in self._cleanup: |
1610 callback(*args, **kwargs) | 1619 callback(*args, **kwargs) |
1611 self.bridge.disconnect(C.SERVICE_PROFILE) | 1620 try: |
1621 self.bridge.disconnect(C.SERVICE_PROFILE) | |
1622 except Exception: | |
1623 log.warning(u"Can't disconnect service profile") | |
1612 | 1624 |
1613 def run(self): | 1625 def run(self): |
1614 reactor.run() | 1626 reactor.run() |
1615 | 1627 |
1616 def stop(self): | 1628 def stop(self): |