Skip to content

Commit

Permalink
[python] Raise exceptions when the controller failed to send commands (
Browse files Browse the repository at this point in the history
  • Loading branch information
erjiaqing authored and pull[bot] committed Aug 14, 2021
1 parent 3b76ac1 commit 3772159
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/controller/python/chip/clusters/CHIPClusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,9 @@ def SendCommand(self, device: ctypes.c_void_p, cluster: str, command: str, endpo
if not func:
raise UnknownCommand(cluster, command)
funcCaller = self._ChipStack.Call if imEnabled else self._ChipStack.CallAsync
funcCaller(lambda: func(device, endpoint, groupid, **args))
res = funcCaller(lambda: func(device, endpoint, groupid, **args))
if res != 0:
raise self._ChipStack.ErrorToException(res)

def ReadAttribute(self, device: ctypes.c_void_p, cluster: str, attribute: str, endpoint: int, groupid: int, imEnabled):
func = getattr(self, "Cluster{}_ReadAttribute{}".format(cluster, attribute), None)
Expand Down
4 changes: 3 additions & 1 deletion src/controller/python/templates/python-CHIPClusters-py.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ class ChipClusters:
if not func:
raise UnknownCommand(cluster, command)
funcCaller = self._ChipStack.Call if imEnabled else self._ChipStack.CallAsync
funcCaller(lambda: func(device, endpoint, groupid, **args))
res = funcCaller(lambda: func(device, endpoint, groupid, **args))
if res != 0:
raise self._ChipStack.ErrorToException(res)

def ReadAttribute(self, device: ctypes.c_void_p, cluster: str, attribute: str, endpoint: int, groupid: int, imEnabled):
func = getattr(self, "Cluster{}_ReadAttribute{}".format(cluster, attribute), None)
Expand Down

0 comments on commit 3772159

Please sign in to comment.