Skip to content

Commit 3287853

Browse files
authored
Merge pull request #178 from zachariahpifer/dont_print_password_in_debug
Don't print password by default in debug
2 parents 410e5a8 + b7385a0 commit 3287853

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

adafruit_esp32spi/adafruit_esp32spi.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,18 @@ class ESP_SPIcontrol: # pylint: disable=too-many-public-methods, too-many-insta
141141

142142
# pylint: disable=too-many-arguments
143143
def __init__(
144-
self, spi, cs_dio, ready_dio, reset_dio, gpio0_dio=None, *, debug=False
144+
self,
145+
spi,
146+
cs_dio,
147+
ready_dio,
148+
reset_dio,
149+
gpio0_dio=None,
150+
*,
151+
debug=False,
152+
debug_show_secrets=False,
145153
):
146154
self._debug = debug
155+
self._debug_show_secrets = debug_show_secrets
147156
self.set_psk = False
148157
self.set_crt = False
149158
self._buffer = bytearray(10)
@@ -325,7 +334,7 @@ def _send_command_get_response(
325334
*,
326335
reply_params=1,
327336
sent_param_len_16=False,
328-
recv_param_len_16=False
337+
recv_param_len_16=False,
329338
):
330339
"""Send a high level SPI command, wait and return the response"""
331340
self._send_command(cmd, params, param_len_16=sent_param_len_16)
@@ -573,7 +582,10 @@ def connect_AP(self, ssid, password, timeout_s=10): # pylint: disable=invalid-n
573582
:param timeout_s: number of seconds until we time out and fail to create AP
574583
"""
575584
if self._debug:
576-
print("Connect to AP", ssid, password)
585+
print(
586+
f"Connect to AP: {ssid=}, password=\
587+
{repr(password if self._debug_show_secrets else '*' * len(password))}"
588+
)
577589
if isinstance(ssid, str):
578590
ssid = bytes(ssid, "utf-8")
579591
if password:

0 commit comments

Comments
 (0)