summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Dybdal <dybber@dybber.dk>2018-10-16 12:36:24 +0200
committerDamien George <damien.p.george@gmail.com>2018-10-19 23:46:10 +1100
commit7795b2e5c3e3dfeb20aaca751c45b4dfceedcc7f (patch)
treedbc3f1c23be678435657fa9e306e9b8e9d461347
parent3c6f639aa58d0558a744af2f2fc32a6debf55c81 (diff)
tools/pyboard.py: In TelnetToSerial.close replace try/except with if.
Some Python linters don't like unconditional except clauses because they catch SystemExit and KeyboardInterrupt, which usually is not the intended behaviour.
-rwxr-xr-xtools/pyboard.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/tools/pyboard.py b/tools/pyboard.py
index 7729022ce..86a07a151 100755
--- a/tools/pyboard.py
+++ b/tools/pyboard.py
@@ -86,6 +86,7 @@ class PyboardError(Exception):
class TelnetToSerial:
def __init__(self, ip, user, password, read_timeout=None):
+ self.tn = None
import telnetlib
self.tn = telnetlib.Telnet(ip, timeout=15)
self.read_timeout = read_timeout
@@ -109,11 +110,8 @@ class TelnetToSerial:
self.close()
def close(self):
- try:
+ if self.tn:
self.tn.close()
- except:
- # the telnet object might not exist yet, so ignore this one
- pass
def read(self, size=1):
while len(self.fifo) < size: