def _on_jabber_rpc_method_response(self, iq): iq.enable('rpc_query') args = xml2py(iq['rpc_query']['method_response']['params']) pid = iq['id'] with self._lock: callback = self._callbacks[pid] del self._callbacks[pid] if(len(args) > 0): callback.set_value(args[0]) else: callback.set_value(None) pass
def _on_jabber_rpc_method_response(self, iq): iq.enable("rpc_query") args = xml2py(iq["rpc_query"]["method_response"]["params"]) pid = iq["id"] with self._lock: callback = self._callbacks[pid] del self._callbacks[pid] if len(args) > 0: callback.set_value(args[0]) else: callback.set_value(None) pass
def _on_jabber_rpc_method_call(self, iq): iq.enable('rpc_query') params = iq['rpc_query']['method_call']['params'] args = xml2py(params) pmethod = iq['rpc_query']['method_call']['method_name'] try: with self._lock: entry = self._entries[pmethod] rules = self._acls[entry.get_endpoint_FQN()] if ACL.check(rules, iq['from'], pmethod): return_value = entry.call_method(args) else: raise AuthorizationException( "Unauthorized access to %s from %s!" % (pmethod, iq['from'])) if return_value is None: return_value = () response = self._client.plugin['xep_0009'].make_iq_method_response( iq['id'], iq['from'], py2xml(*return_value)) response.send() except InvocationException as ie: fault = dict() fault['code'] = 500 fault['string'] = ie.get_message() self._client.plugin['xep_0009']._send_fault(iq, fault2xml(fault)) except AuthorizationException as ae: log.error(ae.get_message()) error = self._client.plugin['xep_0009']._forbidden(iq) error.send() except Exception as e: if isinstance(e, KeyError): log.error("No handler available for %s!" % pmethod) error = self._client.plugin['xep_0009']._item_not_found(iq) else: traceback.print_exc(file=sys.stderr) log.error( "An unexpected problem occurred invoking method %s!" % pmethod) error = self._client.plugin['xep_0009']._undefined_condition( iq) #! print "[REMOTE.PY] _handle_remote_procedure_call AN ERROR SHOULD BE SENT NOW %s " % e error.send()
def _on_jabber_rpc_method_call(self, iq): iq.enable("rpc_query") params = iq["rpc_query"]["method_call"]["params"] args = xml2py(params) pmethod = iq["rpc_query"]["method_call"]["method_name"] try: with self._lock: entry = self._entries[pmethod] rules = self._acls[entry.get_endpoint_FQN()] if ACL.check(rules, iq["from"], pmethod): return_value = entry.call_method(args) else: raise AuthorizationException("Unauthorized access to %s from %s!" % (pmethod, iq["from"])) if return_value is None: return_value = () response = self._client.plugin["xep_0009"].make_iq_method_response( iq["id"], iq["from"], py2xml(*return_value) ) response.send() except InvocationException as ie: fault = dict() fault["code"] = 500 fault["string"] = ie.get_message() self._client.plugin["xep_0009"]._send_fault(iq, fault2xml(fault)) except AuthorizationException as ae: log.error(ae.get_message()) error = self._client.plugin["xep_0009"]._forbidden(iq) error.send() except Exception as e: if isinstance(e, KeyError): log.error("No handler available for %s!", pmethod) error = self._client.plugin["xep_0009"]._item_not_found(iq) else: traceback.print_exc(file=sys.stderr) log.error("An unexpected problem occurred invoking method %s!", pmethod) error = self._client.plugin["xep_0009"]._undefined_condition(iq) #! print "[REMOTE.PY] _handle_remote_procedure_call AN ERROR SHOULD BE SENT NOW %s " % e error.send()