c.disconnect() return response(_("Offline")) if not connected: return response(_("Offline")) return c.daemon.info( ).addCallback(on_info, c ).addErrback(on_info_fail, c) def on_connect_failed(reason, host_id): return response(_("Offline")) if client.connected() and (host, port, "localclient" if not user and host in ("127.0.0.1", "localhost") else user) == client.connection_info(): def on_info(info): return response(_("Connected"), info) return client.daemon.info().addCallback(on_info) else: c = Client() return c.connect(host, port, user, password ).addCallback(on_connect, c, host_id ).addErrback(on_connect_failed, host_id) @export(AUTH_LEVEL_ADMIN) def start_daemon(self, port): """ Starts a local daemon. """
def on_info_fail(reason, c): c.disconnect() return response(_("Offline")) if not connected: return response(_("Offline")) return c.daemon.info().addCallback(on_info, c).addErrback(on_info_fail, c) def on_connect_failed(reason, host_id): return response(_("Offline")) if client.connected() and (host, port, "localclient" if not user and host in ("127.0.0.1", "localhost") else user) == client.connection_info(): def on_info(info): return response(_("Connected"), info) return client.daemon.info().addCallback(on_info) else: c = Client() return c.connect(host, port, user, password).addCallback( on_connect, c, host_id).addErrback(on_connect_failed, host_id) @export def start_daemon(self, port): """ Starts a local daemon. """