klippy: Use newer "except XYZError as e" python syntax
Use the newer syntax for python exceptions. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
d093200966
commit
1bc3e0a678
|
@ -78,7 +78,7 @@ class KeyboardReader:
|
|||
return None
|
||||
try:
|
||||
msg = self.ser.msgparser.create_command(line)
|
||||
except msgproto.error, e:
|
||||
except msgproto.error as e:
|
||||
self.output("Error: %s" % (str(e),))
|
||||
return None
|
||||
return msg
|
||||
|
|
|
@ -107,7 +107,7 @@ class GCodeParser:
|
|||
handler = self.gcode_handlers.get(cmd, self.cmd_default)
|
||||
try:
|
||||
handler(params)
|
||||
except error, e:
|
||||
except error as e:
|
||||
self.respond_error(str(e))
|
||||
except:
|
||||
logging.exception("Exception in command handler")
|
||||
|
@ -224,7 +224,7 @@ class GCodeParser:
|
|||
print_time = self.toolhead.get_last_move_time()
|
||||
try:
|
||||
heater.set_temp(print_time, temp)
|
||||
except heater.error, e:
|
||||
except heater.error as e:
|
||||
self.respond_error(str(e))
|
||||
return
|
||||
if wait:
|
||||
|
@ -264,7 +264,7 @@ class GCodeParser:
|
|||
self.process_commands(deactivate_gcode.split('\n'), need_ack=False)
|
||||
try:
|
||||
self.toolhead.set_extruder(e)
|
||||
except homing.EndstopError, e:
|
||||
except homing.EndstopError as e:
|
||||
self.respond_error(str(e))
|
||||
return
|
||||
self.extruder = e
|
||||
|
@ -296,12 +296,12 @@ class GCodeParser:
|
|||
if speed <= 0.:
|
||||
raise ValueError()
|
||||
self.speed = speed
|
||||
except ValueError, e:
|
||||
except ValueError as e:
|
||||
self.last_position = self.toolhead.get_position()
|
||||
raise error("Unable to parse move '%s'" % (params['#original'],))
|
||||
try:
|
||||
self.toolhead.move(self.last_position, self.speed)
|
||||
except homing.EndstopError, e:
|
||||
except homing.EndstopError as e:
|
||||
self.respond_error(str(e))
|
||||
self.last_position = self.toolhead.get_position()
|
||||
def cmd_G4(self, params):
|
||||
|
@ -327,7 +327,7 @@ class GCodeParser:
|
|||
homing_state.set_no_verify_retract()
|
||||
try:
|
||||
self.toolhead.home(homing_state)
|
||||
except homing.EndstopError, e:
|
||||
except homing.EndstopError as e:
|
||||
self.toolhead.motor_off()
|
||||
self.respond_error(str(e))
|
||||
return
|
||||
|
@ -424,7 +424,7 @@ class GCodeParser:
|
|||
return
|
||||
try:
|
||||
res = self.toolhead.query_endstops()
|
||||
except self.printer.mcu.error, e:
|
||||
except self.printer.mcu.error as e:
|
||||
self.respond_error(str(e))
|
||||
return
|
||||
self.respond(" ".join(["%s:%s" % (name, ["open", "TRIGGERED"][not not t])
|
||||
|
|
|
@ -43,7 +43,7 @@ class Homing:
|
|||
for s, es, last_pos in endstops:
|
||||
try:
|
||||
es.home_wait()
|
||||
except es.error, e:
|
||||
except es.error as e:
|
||||
raise EndstopError("Failed to home stepper %s: %s" % (
|
||||
s.name, str(e)))
|
||||
post_home_pos = s.mcu_stepper.get_mcu_position()
|
||||
|
|
|
@ -61,7 +61,7 @@ class ConfigWrapper:
|
|||
(self.section.lower(), option.lower())] = 1
|
||||
try:
|
||||
v = parser(self.section, option)
|
||||
except self.error, e:
|
||||
except self.error as e:
|
||||
raise
|
||||
except:
|
||||
raise self.error("Unable to parse option '%s' in section '%s'" % (
|
||||
|
@ -199,15 +199,15 @@ class Printer:
|
|||
self.mcu.connect()
|
||||
self.gcode.set_printer_ready(True)
|
||||
self.state_message = message_ready
|
||||
except ConfigParser.Error, e:
|
||||
except ConfigParser.Error as e:
|
||||
logging.exception("Config error")
|
||||
self.state_message = "%s%s" % (str(e), message_restart)
|
||||
self.reactor.update_timer(self.stats_timer, self.reactor.NEVER)
|
||||
except msgproto.error, e:
|
||||
except msgproto.error as e:
|
||||
logging.exception("Protocol error")
|
||||
self.state_message = "%s%s" % (str(e), message_protocol_error)
|
||||
self.reactor.update_timer(self.stats_timer, self.reactor.NEVER)
|
||||
except mcu.error, e:
|
||||
except mcu.error as e:
|
||||
logging.exception("MCU error during connect")
|
||||
self.state_message = "%s%s" % (str(e), message_mcu_connect_error)
|
||||
self.reactor.update_timer(self.stats_timer, self.reactor.NEVER)
|
||||
|
|
|
@ -457,7 +457,7 @@ class MCU:
|
|||
self._emergency_stop_cmd = self.lookup_command("emergency_stop")
|
||||
try:
|
||||
self._reset_cmd = self.lookup_command("reset")
|
||||
except self.serial.msgparser.error, e:
|
||||
except self.serial.msgparser.error as e:
|
||||
pass
|
||||
self.register_msg(self.handle_shutdown, 'shutdown')
|
||||
self.register_msg(self.handle_shutdown, 'is_shutdown')
|
||||
|
|
|
@ -69,7 +69,7 @@ class SerialReader:
|
|||
self.serialport, self.baud, timeout=0)
|
||||
else:
|
||||
self.ser = open(self.serialport, 'rb+')
|
||||
except (OSError, serial.SerialException), e:
|
||||
except (OSError, serial.SerialException) as e:
|
||||
logging.warn("Unable to open port: %s" % (e,))
|
||||
self.reactor.pause(starttime + 5.)
|
||||
continue
|
||||
|
|
Loading…
Reference in New Issue