Commit ddf5eff7 authored by Guillaume Seguin's avatar Guillaume Seguin

Improve reporting of errors in printcore's connect()

parent a1fbee42
...@@ -144,21 +144,21 @@ class printcore(): ...@@ -144,21 +144,21 @@ class printcore():
self.printer_tcp.connect((hostname, port)) self.printer_tcp.connect((hostname, port))
self.printer_tcp.settimeout(self.timeout) self.printer_tcp.settimeout(self.timeout)
self.printer = self.printer_tcp.makefile() self.printer = self.printer_tcp.makefile()
except socket.error: except socket.error as e:
print _("Could not connect to %s:%s:") % (hostname, port) print _("Could not connect to %s:%s:") % (hostname, port)
self.printer = None self.printer = None
self.printer_tcp = None self.printer_tcp = None
traceback.print_exc() print _("Socket error %s: %s") % (e.errno, e.strerror)
return return
else: else:
disable_hup(self.port) disable_hup(self.port)
self.printer_tcp = None self.printer_tcp = None
try: try:
self.printer = Serial(port = self.port, baudrate = self.baud, timeout = 0.25) self.printer = Serial(port = self.port, baudrate = self.baud, timeout = 0.25)
except SerialException: except SerialException as e:
print _("Could not connect to %s at baudrate %s:") % (self.port, self.baud) print _("Could not connect to %s at baudrate %s:") % (self.port, self.baud)
self.printer = None self.printer = None
traceback.print_exc() print _("Serial error: %s") % e
return return
self.stop_read_thread = False self.stop_read_thread = False
self.read_thread = Thread(target = self._listen) self.read_thread = Thread(target = self._listen)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment