Skip to content

Commit 9e254cb

Browse files
gylstorffqchombourger
authored andcommitted
fix: anel.py declare result in front of exception
result is unbound if _receive times out with the follow exeception: mtda-mcom mtda-service[1400]: self._switch(False) mtda-mcom mtda-service[1400]: File "/usr/lib/python3.11/dist-packages/mtda/power/anel.py", line 88, in _switch mtda-mcom mtda-service[1400]: if result == "0": mtda-mcom mtda-service[1400]: ^^^^^^ mtda-mcom mtda-service[1400]: UnboundLocalError: cannot access local variable 'result' where it is not associated with a value
1 parent e8b4a47 commit 9e254cb

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

mtda/power/anel.py

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ def _switch(self, state):
8080
payload = f"Sw_{'on' if state else 'off'}{self._plug}"
8181
self._send(payload)
8282

83+
result = None
8384
try:
8485
result = self._receive().split(':')[5+self._plug].rsplit(',', 1)[1]
8586
except TimeoutError:

0 commit comments

Comments
 (0)