Hi, How do I convert the integer status code (5) into the enum ( grpc.StatusCode.NOT_FOUND)?
https://grpc.github.io/grpc/python/grpc.html#grpc-status-code I tried the following (see Programmatic access to enumeration members and their attributes <https://docs.python.org/3/library/enum.html#programmatic-access-to-enumeration-members-and-their-attributes>) but get an error. >>> import grpc >>> grpc.StatusCode(5) ValueError: 5 is not a valid StatusCode During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/google/home/busunkim/.pyenv/versions/3.7.6/lib/python3.7/enum.py", line 310, in __call__ return cls.__new__(cls, value) File "/usr/local/google/home/busunkim/.pyenv/versions/3.7.6/lib/python3.7/enum.py", line 564, in __new__ raise exc File "/usr/local/google/home/busunkim/.pyenv/versions/3.7.6/lib/python3.7/enum.py", line 548, in __new__ result = cls._missing_(value) File "/usr/local/google/home/busunkim/.pyenv/versions/3.7.6/lib/python3.7/enum.py", line 577, in _missing_ raise ValueError("%r is not a valid %s" % (value, cls.__name__)) ValueError: 5 is not a valid StatusCode *Context*: I'd like turn a status code from a long running operation ( google/longrunning/operations.proto <https://github.com/googleapis/googleapis/blob/cc0c4e7790fc57b3e720dfdd97b71ff85c85c911/google/longrunning/operations.proto#L128-L162> and google/rpc/status.proto <https://github.com/googleapis/googleapis/blob/cc0c4e7790fc57b3e720dfdd97b71ff85c85c911/google/rpc/status.proto#L35-L47>) into a grpc.StatusCode for nicer exceptions in google-api-core <https://github.com/googleapis/python-api-core>. An operation message looks something like this: name: "projects/my-project/instances/test-instance/databases/db2/operations/_auto_op_43eacb16d4b5d9da" metadata { type_url: "type.googleapis.com/google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata" value: "\nHprojects/my-project/instances/test-instance/databases/db2\0223CREATE TABLE Albums (\n id INT64,\n) PRIMARY KEY(id)" } done: true error { code: 9 message: "Duplicate name in schema: Albums." } Thanks! -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/375d3166-2c49-4fb4-becd-44bfbf7b9f3do%40googlegroups.com.
