Fix output in error cases

This commit is contained in:
Grigori Goronzy 2015-11-22 04:27:46 +01:00
parent bb6fd8d8fb
commit 6f77535673

View File

@ -2515,15 +2515,18 @@ class StcGal:
self.protocol.disconnect() self.protocol.disconnect()
return 0 return 0
except NameError as e: except NameError as e:
sys.stdout.flush();
print("Option error: %s" % e, file=sys.stderr) print("Option error: %s" % e, file=sys.stderr)
self.protocol.disconnect() self.protocol.disconnect()
return 1 return 1
except (StcFramingException, StcProtocolException) as e: except (StcFramingException, StcProtocolException) as e:
sys.stdout.flush();
print("Protocol error: %s" % e, file=sys.stderr) print("Protocol error: %s" % e, file=sys.stderr)
self.protocol.disconnect() self.protocol.disconnect()
return 1 return 1
except KeyboardInterrupt: except KeyboardInterrupt:
print("interrupted") sys.stdout.flush();
print("interrupted", file=sys.stderr)
self.protocol.disconnect() self.protocol.disconnect()
return 2 return 2
except serial.SerialException as e: except serial.SerialException as e: