-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy path0010-Python-Use-Python-logging-everywhere-32383.patch
103 lines (93 loc) · 4.76 KB
/
0010-Python-Use-Python-logging-everywhere-32383.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
From 9189b790c7b6f713a40222ddec9ffb99742a05e7 Mon Sep 17 00:00:00 2001
Message-ID: <9189b790c7b6f713a40222ddec9ffb99742a05e7.1711548827.git.stefan@agner.ch>
From: Stefan Agner <stefan@agner.ch>
Date: Fri, 1 Mar 2024 09:43:47 +0100
Subject: [PATCH] [Python] Use Python logging everywhere (#32383)
Do not print to the console but use the Python logging module
explicitly.
---
src/controller/python/chip/ChipDeviceCtrl.py | 23 ++++++++++----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/src/controller/python/chip/ChipDeviceCtrl.py b/src/controller/python/chip/ChipDeviceCtrl.py
index 318c2b56ef..bf9bb245ec 100644
--- a/src/controller/python/chip/ChipDeviceCtrl.py
+++ b/src/controller/python/chip/ChipDeviceCtrl.py
@@ -34,6 +34,7 @@ import copy
import ctypes
import enum
import json
+import logging
import threading
import time
import typing
@@ -265,9 +266,9 @@ class ChipDeviceControllerBase():
def _set_dev_ctrl(self, devCtrl):
def HandleCommissioningComplete(nodeid, err):
if err.is_success:
- print("Commissioning complete")
+ logging.info("Commissioning complete")
else:
- print("Failed to commission: {}".format(err))
+ logging.warning("Failed to commission: {}".format(err))
self.state = DCState.IDLE
self._ChipStack.callbackRes = err
@@ -283,30 +284,30 @@ class ChipDeviceControllerBase():
def HandleOpenWindowComplete(nodeid: int, setupPinCode: int, setupManualCode: str,
setupQRCode: str, err: PyChipError) -> None:
if err.is_success:
- print("Open Commissioning Window complete setting nodeid {} pincode to {}".format(nodeid, setupPinCode))
+ logging.info("Open Commissioning Window complete setting nodeid {} pincode to {}".format(nodeid, setupPinCode))
self._ChipStack.openCommissioningWindowPincode[nodeid] = CommissioningParameters(
setupPinCode=setupPinCode, setupManualCode=setupManualCode.decode(), setupQRCode=setupQRCode.decode())
else:
- print("Failed to open commissioning window: {}".format(err))
+ logging.warning("Failed to open commissioning window: {}".format(err))
self._ChipStack.callbackRes = err
self._ChipStack.completeEvent.set()
def HandleUnpairDeviceComplete(nodeid: int, err: PyChipError):
if err.is_success:
- print("Succesfully unpaired device with nodeid {}".format(nodeid))
+ logging.info("Succesfully unpaired device with nodeid {}".format(nodeid))
else:
- print("Failed to unpair device: {}".format(err))
+ logging.warning("Failed to unpair device: {}".format(err))
self._ChipStack.callbackRes = err
self._ChipStack.completeEvent.set()
def HandlePASEEstablishmentComplete(err: PyChipError):
if not err.is_success:
- print("Failed to establish secure session to device: {}".format(err))
+ logging.warning("Failed to establish secure session to device: {}".format(err))
self._ChipStack.callbackRes = err.to_exception()
else:
- print("Established secure session with Device")
+ logging.info("Established secure session with Device")
if self.state != DCState.COMMISSIONING:
# During Commissioning, HandlePASEEstablishmentComplete will also be called,
@@ -785,7 +786,7 @@ class ChipDeviceControllerBase():
res = self._ChipStack.Call(lambda: self._dmLib.pychip_GetDeviceBeingCommissioned(
self.devCtrl, nodeid, byref(returnDevice)), timeoutMs)
if res.is_success:
- print('Using PASE connection')
+ logging.info('Using PASE connection')
return DeviceProxyWrapper(returnDevice)
class DeviceAvailableClosure():
@@ -1151,7 +1152,7 @@ class ChipDeviceControllerBase():
# Wildcard
pass
elif not isinstance(pathTuple, tuple):
- print(type(pathTuple))
+ logging.debug(type(pathTuple))
if isinstance(pathTuple, int):
endpoint = pathTuple
elif issubclass(pathTuple, ClusterObjects.Cluster):
@@ -1426,7 +1427,7 @@ class ChipDeviceControllerBase():
raise UnknownCommand(cluster, command)
try:
res = asyncio.run(self.SendCommand(nodeid, endpoint, req))
- print(f"CommandResponse {res}")
+ logging.debug(f"CommandResponse {res}")
return (0, res)
except InteractionModelError as ex:
return (int(ex.status), None)
--
2.44.0