make pyterm nicely fails if no port is available

This commit is contained in:
Alexandre Abadie 2015-11-20 17:50:40 +01:00
parent 3fc71ef694
commit 0d9f14c848

View File

@ -210,7 +210,12 @@ class SerCmd(cmd.Cmd):
# otherwise go for the serial port # otherwise go for the serial port
elif self.port: elif self.port:
self.logger.info("Connect to serial port %s" % self.port) self.logger.info("Connect to serial port %s" % self.port)
try:
self.serial_connect() 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 # wait until connection is established and fire startup
# commands to the node # commands to the node