def get_indx(self): return_d = Deferred() def authed_cb(): logging.debug("in service_tweets - Authed Callback") logging.debug( "in service_tweets - get_indx authclient Auth status: {0}". format(authclient.is_authed)) def token_cb(token): self.indx_con = IndxClient(self.credentials['address'], self.credentials['box'], appid, token=token, client=authclient.client) return_d.callback(True) authclient.get_token(self.credentials['box']).addCallbacks( token_cb, return_d.errback) def authed_cb_fail(re): logging.debug( "in service tweets - get_indx/authed_cb failed for reason {0}". format(re)) return_d.errback logging.debug("in service_tweets - get_indx") authclient = IndxClientAuth(self.credentials['address'], appid) authclient.auth_plain(self.credentials['username'], self.credentials['password']).addCallbacks( lambda response: authed_cb(), authed_cb_fail) return return_d
def auth_and_get_token(self, get_token): """ Authenticate, get a token and call it back to the deferred. """ return_d = Deferred() def authed_cb(): def token_cb(token): if token is not None: self.token = token return_d.callback(token) else: return_d.callback(None) if get_token: authclient.get_token(self.args['box']).addCallbacks( token_cb, return_d.errback) else: token_cb(None) authclient = IndxClientAuth(self.args['server'], self.appid) self.client = authclient.client authclient.auth_plain(self.args['username'], self.args['password']).addCallbacks( lambda response: authed_cb(), return_d.errback) return return_d
def get_indx(self): return_d = Deferred() def authed_cb(): logging.debug("in service_tweets - Authed Callback") logging.debug("in service_tweets - get_indx authclient Auth status: {0}".format(authclient.is_authed)) def token_cb(token): self.indx_con = IndxClient( self.config["address"], self.config["box"], appid, token=token, client=authclient.client ) return_d.callback(True) authclient.get_token(self.config["box"]).addCallbacks(token_cb, return_d.errback) def authed_cb_fail(re): logging.debug("in service tweets - get_indx/authed_cb failed for reason {0}".format(re)) return_d.errback logging.debug("in service_instagram - get_indx") authclient = IndxClientAuth(self.config["address"], appid) authclient.auth_plain(self.config["user"], self.config["password"]).addCallbacks( lambda response: authed_cb(), authed_cb_fail ) return return_d
def keystore_cb(local_key): # start sync clientauth = IndxClientAuth(remote_server_url, self.APPID) def authed_cb(empty): logging.debug("IndxSync sync_boxes authed_cb") def token_cb(remote_token): logging.debug("IndxSync sync_boxes token_cb") client = IndxClient(remote_server_url, remote_box, self.APPID, client = clientauth.client, token = remote_token, keystore = self.keystore) def updated_cb(empty): def pushed_cb(empty): def observer(data): if data.get('action') == 'diff' and data.get('operation') == 'update': diff = data['data'] def done_cb(empty): logging.debug("IndxSync updating from a websocket done.") def err_cb(failure): logging.error("IndxSync updating from a websocket error: {0}".format(failure)) self.update_to_latest_version(client, remote_server_url, remote_box, diff_in = diff).addCallbacks(done_cb, err_cb) else: logging.error("Sync: Unknown data message from WebSocket: {0}".format(data)) # auths and sets up listening for diffs, filtering them and passing them to the observer if websocket is None: wsclient = client.connect_ws(local_key['key']['private'], local_key_hash, observer, remote_encpk2, self.webserver) # open a new socket else: websocket.listen_remote(local_key['key']['private'], local_key_hash, observer, remote_encpk2) # use an existing websocket next_model(None) if not include_push_all: pushed_cb(None) return # push the whole box to the remote box def latest_cb(graph): def ver_cb(version): client.update_raw(version, graph.to_flat_json()).addCallbacks(pushed_cb, return_d.errback) client.get_version().addCallbacks(lambda resp: ver_cb(resp['data']), return_d.errback) self.root_store.get_latest(render_json = False).addCallbacks(latest_cb, return_d.errback) # compare local version to previous, and update one of them, or both self.update_to_latest_version(client, remote_server_url, remote_box).addCallbacks(updated_cb, return_d.errback) clientauth.get_token(remote_box).addCallbacks(token_cb, return_d.errback) clientauth.auth_keys(local_key['key']['private'], local_key_hash, remote_encpk2).addCallbacks(authed_cb, return_d.errback)
def get_indx(server_url, box, user, password, appid): return_d = Deferred() def authed_cb(): def token_cb(token): indx = IndxClient(server_url, box, appid, token = token) return_d.callback(indx) authclient.get_token(box).addCallbacks(token_cb, return_d.errback) authclient = IndxClientAuth(server_url, appid) authclient.auth_plain(user, password).addCallbacks(lambda response: authed_cb(), return_d.errback) return return_d
def get_indx(self, server_url): indx_d = Deferred() def authed_cb(): def token_cb(token): indx = IndxClient(server_url, self.config_box, "INDX_Fitbit_Harvester", token = token, client = authclient.client) indx_d.callback(indx) authclient.get_token(self.config_box).addCallbacks(token_cb, indx_d.errback) authclient = IndxClientAuth(server_url, "INDX_Fitbit_Harvester") authclient.auth_plain(self.config_indx_user, self.config_indx_pass).addCallbacks(lambda response: authed_cb(), indx_d.errback) return indx_d
def get_indx(self, server_url): indx_d = Deferred() def authed_cb(): def token_cb(token): indx = IndxClient(server_url, self.config_box, "INDX_Nike_Harvester", token = token, client = authclient.client) indx_d.callback(indx) authclient.get_token(self.config_box).addCallbacks(token_cb, indx_d.errback) authclient = IndxClientAuth(server_url, "INDX_Nike_Harvester") authclient.auth_plain(self.config_indx_user, self.config_indx_pass).addCallbacks(lambda response: authed_cb(), indx_d.errback) return indx_d
def get_indx(server_url, box, user, password): indx_d = Deferred() def authed_cb(resp): logging.debug("authentication response: {0}".format(resp)) logging.debug("authenticated, getting the indx client token"); def token_cb(token): indx = IndxClient(server_url, box, "Slicer", token = token, client = authclient.client) logging.debug("Got the indx client token"); indx_d.callback(indx) authclient.get_token(box).addCallbacks(token_cb, indx_d.errback) logging.debug("creating authclient") authclient = IndxClientAuth(server_url, "Slicer") logging.debug("authclient authenticate (plain)") authclient.auth_plain(user, password).addCallbacks(authed_cb, indx_d.errback) return indx_d
def auth_and_get_token(self, get_token): """ Authenticate, get a token and call it back to the deferred. """ return_d = Deferred() def authed_cb(): def token_cb(token): if token is not None: self.token = token return_d.callback(token) else: return_d.callback(None) if get_token: authclient.get_token(self.args['box']).addCallbacks(token_cb, return_d.errback) else: token_cb(None) authclient = IndxClientAuth(self.args['server'], self.appid) self.client = authclient.client authclient.auth_plain(self.args['username'], self.args['password']).addCallbacks(lambda response: authed_cb(), return_d.errback) return return_d