From 3a81844a1773748eac57e8c17016a6fed46eaf2e Mon Sep 17 00:00:00 2001 From: Grigori Goronzy Date: Tue, 24 Nov 2015 01:42:53 +0100 Subject: [PATCH] frontend: prefer to catch SerialException It's a subclass of IOError, which we were catching first. --- stcgal/frontend.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stcgal/frontend.py b/stcgal/frontend.py index f3ac224..d3ef877 100644 --- a/stcgal/frontend.py +++ b/stcgal/frontend.py @@ -139,11 +139,6 @@ class StcGal: else: self.protocol.disconnect() return 0 - except IOError as e: - sys.stdout.flush(); - print("I/O error: %s" % e, file=sys.stderr) - self.protocol.disconnect() - return 1 except NameError as e: sys.stdout.flush(); print("Option error: %s" % e, file=sys.stderr) @@ -162,6 +157,11 @@ class StcGal: except serial.SerialException as e: print("Serial port error: %s" % e, file=sys.stderr) return 1 + except IOError as e: + sys.stdout.flush(); + print("I/O error: %s" % e, file=sys.stderr) + self.protocol.disconnect() + return 1 def cli():