gnetclisdk 1.0.63__py3-none-any.whl → 1.0.69__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 +35 -3
- {gnetclisdk-1.0.63.dist-info → gnetclisdk-1.0.69.dist-info}/METADATA +1 -1
- {gnetclisdk-1.0.63.dist-info → gnetclisdk-1.0.69.dist-info}/RECORD +5 -5
- {gnetclisdk-1.0.63.dist-info → gnetclisdk-1.0.69.dist-info}/WHEEL +0 -0
- {gnetclisdk-1.0.63.dist-info → gnetclisdk-1.0.69.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,31 @@ 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 = ""
|
122
|
+
metadata = None
|
123
|
+
if error_info:
|
124
|
+
reason = error_info.reason
|
125
|
+
metadata = dict(error_info.metadata)
|
97
126
|
if code == grpc.StatusCode.UNAVAILABLE and detail == "not ready":
|
98
127
|
return NotReady, ""
|
99
128
|
if code == grpc.StatusCode.UNAUTHENTICATED:
|
@@ -103,10 +132,13 @@ def parse_grpc_error(grpc_error: grpc.aio.AioRpcError) -> Tuple[Type[GnetcliExce
|
|
103
132
|
if code == grpc.StatusCode.OUT_OF_RANGE:
|
104
133
|
return UnknownDevice, detail
|
105
134
|
if code == grpc.StatusCode.INTERNAL:
|
106
|
-
if
|
135
|
+
if reason == "error_eof": # new way: pass errors using error_details
|
136
|
+
verbose = str(metadata)
|
137
|
+
return EOFError, verbose
|
138
|
+
elif detail == "auth_device_error":
|
107
139
|
verbose = ""
|
108
140
|
return DeviceAuthError, verbose
|
109
|
-
|
141
|
+
elif detail in {"connection_error", "busy_error"}:
|
110
142
|
verbose = ""
|
111
143
|
return DeviceConnectError, verbose
|
112
144
|
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=FVaj3X5163yPFsglfsw3MaZ9r3OE_Cih9N7EL1NTGgo,3791
|
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.69.dist-info/METADATA,sha256=mXbSdtY2YHGddiq8oalZy0UyWG_lMNLoF-jQTqH_2aA,1793
|
9
|
+
gnetclisdk-1.0.69.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
10
|
+
gnetclisdk-1.0.69.dist-info/top_level.txt,sha256=MNjS8LEt6d2rZ-dUbV2cnqkuTMu3EqEL2eiSvUZuUlA,11
|
11
|
+
gnetclisdk-1.0.69.dist-info/RECORD,,
|
File without changes
|
File without changes
|