From 0d9f14c848ec2877cbcd6f66c6f52a59ded22949 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Fri, 20 Nov 2015 17:50:40 +0100 Subject: [PATCH] make pyterm nicely fails if no port is available --- dist/tools/pyterm/pyterm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dist/tools/pyterm/pyterm b/dist/tools/pyterm/pyterm index ba7b7e7daf..32ca955c4d 100755 --- a/dist/tools/pyterm/pyterm +++ b/dist/tools/pyterm/pyterm @@ -210,7 +210,12 @@ class SerCmd(cmd.Cmd): # otherwise go for the serial port elif self.port: self.logger.info("Connect to serial port %s" % self.port) - self.serial_connect() + try: + self.serial_connect() + except OSError as e: + self.logger.error("Cannot connect to serial port {}: {}" + .format(self.port, e.strerror)) + sys.exit(1) # wait until connection is established and fire startup # commands to the node