Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
service.CallMethod(method, controller, proto_request, callback)
except Exception, e:
raise error.RpcError(unicode(e))
# Return an RPC response, with payload defined in the callback
response = rpc_pb.Response()
if callback.response:
response.callback = True
response.response_proto = callback.response.SerializeToString()
else:
response.callback = callback.invoked
# Check to see if controller has been set to not success by user.
if controller.failed():
response.error = controller.error()
response.error_reason = rpc_pb.RPC_FAILED
return response
def parseServiceRequest(self, bytestream_from_client):
'''Validate the data stream received from the client.'''
# Convert the client request into a PB Request object
request = rpc_pb.Request()
# Catch anything which isn't a valid PB bytestream
try:
request.MergeFromString(bytestream_from_client)
except Exception, e:
raise error.BadRequestDataError("Invalid request from \
client (decodeError): " + str(e))
# Check the request is correctly initialized
if not request.IsInitialized():
raise error.BadRequestDataError("Client request is missing \
mandatory fields")
log.debug('Request = %s' % request)
return request
def __init__(self, message):
super(MethodNotFoundError, self).__init__(
message, rpc_pb.METHOD_NOT_FOUND)
def __init__(self, message):
super(BadRequestDataError, self).__init__(
message, rpc_pb.BAD_REQUEST_DATA)
def parseServiceRequest(self, bytestream_from_client):
'''Validate the data stream received from the client.'''
# Convert the client request into a PB Request object
request = rpc_pb.Request()
# Catch anything which isn't a valid PB bytestream
try:
request.MergeFromString(bytestream_from_client)
except Exception, e:
raise error.BadRequestDataError("Invalid request from \
client (decodeError): " + str(e))
# Check the request is correctly initialized
if not request.IsInitialized():
raise error.BadRequestDataError("Client request is missing \
mandatory fields")
log.debug('Request = %s' % request)
return request
def __init__(self, message):
super(UnknownHostError, self).__init__(message, rpc_pb.UNKNOWN_HOST)
def __init__(self, message):
super(BadRequestProtoError, self).__init__(
message, rpc_pb.BAD_REQUEST_PROTO)
def __init__(self, message):
super(RpcError, self).__init__(message, rpc_pb.RPC_ERROR)
def __init__(self, message):
super(ServiceNotFoundError, self).__init__(
message, rpc_pb.SERVICE_NOT_FOUND)
def __init__(self, message):
super(InvalidRequestProtoError, self).__init__(
message, rpc_pb.INVALID_REQUEST_PROTO)