diff --git a/ptsl/PTSL_pb2_grpc.py b/ptsl/PTSL_pb2_grpc.py index f77ce57..a538708 100644 --- a/ptsl/PTSL_pb2_grpc.py +++ b/ptsl/PTSL_pb2_grpc.py @@ -17,15 +17,15 @@ def __init__(self, channel): channel: A grpc.Channel. """ self.SendGrpcRequest = channel.unary_unary( - '/ptsl.PTSL/SendGrpcRequest', - request_serializer=PTSL__pb2.Request.SerializeToString, - response_deserializer=PTSL__pb2.Response.FromString, - ) + '/ptsl.PTSL/SendGrpcRequest', + request_serializer=PTSL__pb2.Request.SerializeToString, + response_deserializer=PTSL__pb2.Response.FromString, + ) self.SendGrpcStreamingRequest = channel.unary_stream( - '/ptsl.PTSL/SendGrpcStreamingRequest', - request_serializer=PTSL__pb2.Request.SerializeToString, - response_deserializer=PTSL__pb2.Response.FromString, - ) + '/ptsl.PTSL/SendGrpcStreamingRequest', + request_serializer=PTSL__pb2.Request.SerializeToString, + response_deserializer=PTSL__pb2.Response.FromString, + ) class PTSLServicer(object): @@ -52,23 +52,24 @@ def SendGrpcStreamingRequest(self, request, context): def add_PTSLServicer_to_server(servicer, server): rpc_method_handlers = { - 'SendGrpcRequest': grpc.unary_unary_rpc_method_handler( - servicer.SendGrpcRequest, - request_deserializer=PTSL__pb2.Request.FromString, - response_serializer=PTSL__pb2.Response.SerializeToString, - ), - 'SendGrpcStreamingRequest': grpc.unary_stream_rpc_method_handler( - servicer.SendGrpcStreamingRequest, - request_deserializer=PTSL__pb2.Request.FromString, - response_serializer=PTSL__pb2.Response.SerializeToString, - ), + 'SendGrpcRequest': grpc.unary_unary_rpc_method_handler( + servicer.SendGrpcRequest, + request_deserializer=PTSL__pb2.Request.FromString, + response_serializer=PTSL__pb2.Response.SerializeToString, + ), + 'SendGrpcStreamingRequest': grpc.unary_stream_rpc_method_handler( + servicer.SendGrpcStreamingRequest, + request_deserializer=PTSL__pb2.Request.FromString, + response_serializer=PTSL__pb2.Response.SerializeToString, + ), } generic_handler = grpc.method_handlers_generic_handler( - 'ptsl.PTSL', rpc_method_handlers) + 'ptsl.PTSL', rpc_method_handlers) server.add_generic_rpc_handlers((generic_handler,)) - # This class is part of an EXPERIMENTAL API. + + class PTSL(object): """* Service for handling different types of ProTools commands using PTSL Client. @@ -76,34 +77,34 @@ class PTSL(object): @staticmethod def SendGrpcRequest(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): return grpc.experimental.unary_unary(request, target, '/ptsl.PTSL/SendGrpcRequest', - PTSL__pb2.Request.SerializeToString, - PTSL__pb2.Response.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + PTSL__pb2.Request.SerializeToString, + PTSL__pb2.Response.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) @staticmethod def SendGrpcStreamingRequest(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): return grpc.experimental.unary_stream(request, target, '/ptsl.PTSL/SendGrpcStreamingRequest', - PTSL__pb2.Request.SerializeToString, - PTSL__pb2.Response.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + PTSL__pb2.Request.SerializeToString, + PTSL__pb2.Response.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) diff --git a/ptsl/client.py b/ptsl/client.py index 1655b12..f52e37e 100644 --- a/ptsl/client.py +++ b/ptsl/client.py @@ -152,12 +152,12 @@ def run(self, operation: Operation) -> None: operation.status = response.header.status if response.header.status == pt.Failed: - cleaned_response_error_json = response.response_error_json - #self._response_error_json_cleanup( - #response.response_error_json) - command_error = json_format.Parse(cleaned_response_error_json, + cleaned_response_error_json = response.response_error_json + # self._response_error_json_cleanup( + # response.response_error_json) + command_errors = json_format.Parse(cleaned_response_error_json, pt.ResponseError()) - raise CommandError(command_error.errors) + raise CommandError(command_errors.errors) elif response.header.status == pt.Completed: self._handle_completed_response(operation, response) diff --git a/ptsl/errors.py b/ptsl/errors.py index 7980fef..3e58d60 100644 --- a/ptsl/errors.py +++ b/ptsl/errors.py @@ -27,14 +27,14 @@ def is_warning(self) -> bool: """ `True` if command error message is marked as a warning. """ - return self.error_response[0].is_warning + return self.error_responses[0].is_warning @property def error_type(self) -> CommandErrorType: """ :class:`ptsl.PTSL_pb2.CommandErrorType` enumeration value. """ - return self.error_response[0].command_error_type + return self.error_responses[0].command_error_type @property def error_name(self) -> Optional[str]: @@ -51,4 +51,4 @@ def message(self) -> str: """ Error message as returned by the client. """ - return self.error_response[0].command_error_message + return self.error_responses[0].command_error_message diff --git a/tests/test_client.py b/tests/test_client.py index b59239c..1cc00df 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -51,7 +51,6 @@ def assert_get_track_list_called(self): def message_to_json(self, message): return json_format.MessageToJson( message, - including_default_value_fields=True, preserving_proto_field_name=True) def SendGrpcRequest( @@ -83,18 +82,20 @@ def SendGrpcRequest( elif request.header.command == pt.Copy: status = pt.Failed error_body_json = self.message_to_json( - pt.CommandError( + pt.ResponseError(errors=[pt.CommandError( command_error_type=pt.PT_UnknownError, command_error_message="Test error response", is_warning=False) - ) + ])) elif request.header.command == pt.Paste: status = pt.Failed error_body_json = """ - { - "command_error_type": "PT_CopyOptionCopy", - "command_error_message": "Test error message", - "is_warning": true + { + "errors": [ { + "command_error_type": "PT_CopyOptionCopy", + "command_error_message": "Test error message", + "is_warning": true + } ] } """