34 from functools
import partial
42 call_service_msg_fields = [(
True,
"service", string_types),
43 (
False,
"fragment_size", (int, type(
None))),
44 (
False,
"compression", string_types)]
50 Capability.__init__(self, protocol)
53 protocol.register_operation(
"call_service", self.
call_service)
57 cid = message.get(
"id",
None)
63 service = message[
"service"]
64 fragment_size = message.get(
"fragment_size",
None)
65 compression = message.get(
"compression",
"none")
66 args = message.get(
"args", [])
68 if CallService.services_glob
is not None and CallService.services_glob:
69 self.protocol.log(
"debug",
"Service security glob enabled, checking service: " + service)
71 for glob
in CallService.services_glob:
72 if (fnmatch.fnmatch(service, glob)):
73 self.protocol.log(
"debug",
"Found match with glob " + glob +
", continuing service call...")
77 self.protocol.log(
"warn",
"No match found for service, cancelling service call for: " + service)
80 self.protocol.log(
"debug",
"No service security glob, not checking service call.")
86 s_cb = partial(self.
_success, cid, service, fragment_size, compression)
87 e_cb = partial(self.
_failure, cid, service)
92 def _success(self, cid, service, fragment_size, compression, message):
94 "op":
"service_response",
100 outgoing_message[
"id"] = cid
102 self.protocol.send(outgoing_message)
105 self.protocol.log(
"error",
"call_service %s: %s" %
106 (type(exc).__name__, str(exc)), cid)
109 "op":
"service_response",
115 outgoing_message[
"id"] = cid
116 self.protocol.send(outgoing_message)
121 return service[:service.find(
'#')]
129 return service[service.find(
'#') + 1:]
def extract_id(service, cid)
def trim_servicename(service)
def _success(self, cid, service, fragment_size, compression, message)
def _failure(self, cid, service, exc)
def __init__(self, protocol)
list call_service_msg_fields
def basic_type_check(self, msg, types_info)
def call_service(self, message)