Skip to content

Commit

Permalink
Backwards compatibility if v2 is not present
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmittag committed Sep 30, 2024
1 parent cc19d2c commit e31ef8a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions kuksa-client/kuksa_client/grpc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,10 @@ def set(
try:
resp = self.client_stub_v2.PublishValueRequest(req, **rpc_kwargs)
except RpcError as exc:
raise VSSClientError.from_grpc_error(exc) from exc
if exc.code() == grpc.StatusCode.UNIMPLEMENTED:
self.set(updates)
else:
raise VSSClientError.from_grpc_error(exc) from exc

@check_connected
def subscribe(
Expand Down Expand Up @@ -1304,7 +1307,10 @@ def subscribe(
for path, dp in resp.entries.items()
]
except RpcError as exc:
raise VSSClientError.from_grpc_error(exc) from exc
if exc.code() == grpc.StatusCode.UNIMPLEMENTED:
self.subscribe(entries)
else:
raise VSSClientError.from_grpc_error(exc) from exc

@check_connected
def authorize(self, token: str, **rpc_kwargs) -> str:
Expand Down
10 changes: 8 additions & 2 deletions kuksa-client/kuksa_client/grpc/aio.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,10 @@ async def set(
try:
resp = await self.client_stub_v2.PublishValue(req, **rpc_kwargs)
except AioRpcError as exc:
raise VSSClientError.from_grpc_error(exc) from exc
if exc.code() == grpc.StatusCode.UNIMPLEMENTED:
await self.set(updates)
else:
raise VSSClientError.from_grpc_error(exc) from exc

@check_connected_async_iter
async def subscribe(
Expand Down Expand Up @@ -466,7 +469,10 @@ async def subscribe(
for path, dp in resp.entries.items()
]
except AioRpcError as exc:
raise VSSClientError.from_grpc_error(exc) from exc
if exc.code() == grpc.StatusCode.UNIMPLEMENTED:
await self.subscribe(entries)
else:
raise VSSClientError.from_grpc_error(exc) from exc

@check_connected_async
async def authorize(self, token: str, **rpc_kwargs) -> str:
Expand Down

0 comments on commit e31ef8a

Please sign in to comment.