Skip to content
Snippets Groups Projects
Commit 7795b2e5 authored by Martin Dybdal's avatar Martin Dybdal Committed by Damien George
Browse files

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.
parent 3c6f639a
Branches
No related tags found
No related merge requests found
...@@ -86,6 +86,7 @@ class PyboardError(Exception): ...@@ -86,6 +86,7 @@ class PyboardError(Exception):
class TelnetToSerial: class TelnetToSerial:
def __init__(self, ip, user, password, read_timeout=None): def __init__(self, ip, user, password, read_timeout=None):
self.tn = None
import telnetlib import telnetlib
self.tn = telnetlib.Telnet(ip, timeout=15) self.tn = telnetlib.Telnet(ip, timeout=15)
self.read_timeout = read_timeout self.read_timeout = read_timeout
...@@ -109,11 +110,8 @@ class TelnetToSerial: ...@@ -109,11 +110,8 @@ class TelnetToSerial:
self.close() self.close()
def close(self): def close(self):
try: if self.tn:
self.tn.close() self.tn.close()
except:
# the telnet object might not exist yet, so ignore this one
pass
def read(self, size=1): def read(self, size=1):
while len(self.fifo) < size: while len(self.fifo) < size:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment