def call_action(self, name, *args, **kwargs): """ Calls an action by name. """ return_d = Deferred() action = self.actions[name] f = action['f'] self.check_args(action['args']) def do_call(): f(*args, **kwargs).addCallbacks( lambda status: return_d.callback( self.parse_status(name, status)), return_d.errback) if not self.token: def token_cb(token): if not self.indx: self.indx = IndxClient(self.args['server'], self.args['box'], self.appid, token=token, client=self.client) do_call() self.auth_and_get_token(IndxClient.requires_token(f)).addCallbacks( token_cb, return_d.errback) else: do_call() return return_d
def call_action(self, name, *args, **kwargs): """ Calls an action by name. """ return_d = Deferred() action = self.actions[name] f = action['f'] self.check_args(action['args']) def do_call(): f(*args, **kwargs).addCallbacks(lambda status: return_d.callback(self.parse_status(name, status)), return_d.errback) if not self.token: def token_cb(token): if not self.indx: self.indx = IndxClient(self.args['server'], self.args['box'], self.appid, token = token, client = self.client) do_call() self.auth_and_get_token(IndxClient.requires_token(f)).addCallbacks(token_cb, return_d.errback) else: do_call() return return_d