gnetclisdk 1.0.62__py3-none-any.whl → 1.0.68__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gnetclisdk/exceptions.py +32 -3
- {gnetclisdk-1.0.62.dist-info → gnetclisdk-1.0.68.dist-info}/METADATA +1 -1
- {gnetclisdk-1.0.62.dist-info → gnetclisdk-1.0.68.dist-info}/RECORD +5 -5
- {gnetclisdk-1.0.62.dist-info → gnetclisdk-1.0.68.dist-info}/WHEEL +0 -0
- {gnetclisdk-1.0.62.dist-info → gnetclisdk-1.0.68.dist-info}/top_level.txt +0 -0
gnetclisdk/exceptions.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
from typing import Optional, Sequence, Tuple, Type, Union
|
2
|
-
|
2
|
+
from google.rpc import error_details_pb2, status_pb2
|
3
3
|
import grpc.aio
|
4
4
|
|
5
5
|
MetadataType = Sequence[Tuple[str, Union[str, bytes]]]
|
@@ -65,6 +65,14 @@ class ExecError(GnetcliException):
|
|
65
65
|
pass
|
66
66
|
|
67
67
|
|
68
|
+
class EOFError(GnetcliException):
|
69
|
+
"""
|
70
|
+
EOF error.
|
71
|
+
"""
|
72
|
+
|
73
|
+
pass
|
74
|
+
|
75
|
+
|
68
76
|
class NotReady(GnetcliException):
|
69
77
|
"""
|
70
78
|
Server is not ready.
|
@@ -90,10 +98,28 @@ class PermissionDenied(GnetcliException):
|
|
90
98
|
|
91
99
|
|
92
100
|
def parse_grpc_error(grpc_error: grpc.aio.AioRpcError) -> Tuple[Type[GnetcliException], str]:
|
101
|
+
rich_statuses = []
|
102
|
+
for key, value in grpc_error.trailing_metadata():
|
103
|
+
if key == "grpc-status-details-bin":
|
104
|
+
rich_status = status_pb2.Status.FromString(value)
|
105
|
+
for rdetail in rich_status.details:
|
106
|
+
if rdetail.Is(error_details_pb2.ErrorInfo.DESCRIPTOR):
|
107
|
+
error_info = error_details_pb2.ErrorInfo()
|
108
|
+
rdetail.Unpack(error_info)
|
109
|
+
rich_statuses.append(error_info)
|
110
|
+
break
|
111
|
+
error_info = None
|
112
|
+
if len(rich_statuses) > 1:
|
113
|
+
raise Exception("unexpected rich_statuses len %s", len(rich_statuses))
|
114
|
+
elif len(rich_statuses) == 1:
|
115
|
+
error_info = rich_statuses[0]
|
116
|
+
|
93
117
|
code = grpc_error.code()
|
94
118
|
detail = ""
|
95
119
|
if grpc_error.details():
|
96
120
|
detail = grpc_error.details() # type: ignore
|
121
|
+
reason = error_info.reason
|
122
|
+
metadata = dict(error_info.metadata)
|
97
123
|
if code == grpc.StatusCode.UNAVAILABLE and detail == "not ready":
|
98
124
|
return NotReady, ""
|
99
125
|
if code == grpc.StatusCode.UNAUTHENTICATED:
|
@@ -103,10 +129,13 @@ def parse_grpc_error(grpc_error: grpc.aio.AioRpcError) -> Tuple[Type[GnetcliExce
|
|
103
129
|
if code == grpc.StatusCode.OUT_OF_RANGE:
|
104
130
|
return UnknownDevice, detail
|
105
131
|
if code == grpc.StatusCode.INTERNAL:
|
106
|
-
if
|
132
|
+
if reason == "error_eof": # new way: pass errors using error_details
|
133
|
+
verbose = str(metadata)
|
134
|
+
return EOFError, verbose
|
135
|
+
elif detail == "auth_device_error":
|
107
136
|
verbose = ""
|
108
137
|
return DeviceAuthError, verbose
|
109
|
-
|
138
|
+
elif detail in {"connection_error", "busy_error"}:
|
110
139
|
verbose = ""
|
111
140
|
return DeviceConnectError, verbose
|
112
141
|
elif detail in {"exec_error", "generic_error"}:
|
@@ -1,11 +1,11 @@
|
|
1
1
|
gnetclisdk/auth.py,sha256=GwM7H7Ecb-gwqUTkQorifNB_mtnZfgeS46gOW2Vx1U4,1246
|
2
2
|
gnetclisdk/client.py,sha256=VjbXL11xAUYRX5e6tnedTt6X7_lvvhysYm04EFbhtl8,19773
|
3
|
-
gnetclisdk/exceptions.py,sha256
|
3
|
+
gnetclisdk/exceptions.py,sha256=-dw6sIkPySymabb4XRcUA3FeqpJOtZU-t21sqvEQa8E,3728
|
4
4
|
gnetclisdk/interceptors.py,sha256=apj3l4lnR2ZcsA49odptrBC0kTDmP6Mp0EzYkeEJz9Y,7010
|
5
5
|
gnetclisdk/proto/server_pb2.py,sha256=OQsW6Oh38zf-h1ctcNyeOyxjl5wzWm_D9SRT2Usx5q4,8083
|
6
6
|
gnetclisdk/proto/server_pb2.pyi,sha256=th-HnFVkR1ZEY-XmFmk8VMfDj_4uFAoSAXH61mSlVec,8295
|
7
7
|
gnetclisdk/proto/server_pb2_grpc.py,sha256=H_CmevWcjvGTvp4TmzEV-TJRPq2SsQ6UgoCDc-hosyo,12805
|
8
|
-
gnetclisdk-1.0.
|
9
|
-
gnetclisdk-1.0.
|
10
|
-
gnetclisdk-1.0.
|
11
|
-
gnetclisdk-1.0.
|
8
|
+
gnetclisdk-1.0.68.dist-info/METADATA,sha256=7pCJowx1b22jywhn6kJgLE7VxMBEpR2xUae4IyVUsQM,1793
|
9
|
+
gnetclisdk-1.0.68.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
10
|
+
gnetclisdk-1.0.68.dist-info/top_level.txt,sha256=MNjS8LEt6d2rZ-dUbV2cnqkuTMu3EqEL2eiSvUZuUlA,11
|
11
|
+
gnetclisdk-1.0.68.dist-info/RECORD,,
|
File without changes
|
File without changes
|