Skip to content

Commit

Permalink
Python 3: Fix except syntax
Browse files Browse the repository at this point in the history
Change generated by:

    python-modernize -wnf lib2to3.fixes.fix_except
  • Loading branch information
hroncok committed Feb 13, 2018
1 parent 98f66bd commit fcb3027
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion calibrateextruder.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def gettemp(p):
"""[1:-1].encode('utf-8') % (sys.argv[0], n, k, temp, tempmax, port if port else 'auto')
try:
opts, args = getopt.getopt(sys.argv[1:], "hl:s:t:p:", ["help", "length=", "steps=", "temp=", "port="])
except getopt.GetoptError, err:
except getopt.GetoptError as err:
print str(err)
print help
sys.exit(2)
Expand Down
2 changes: 1 addition & 1 deletion plater.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

try:
opts, args = getopt.getopt(sys.argv[1:], "hV", ["help", "version"])
except getopt.GetoptError, err:
except getopt.GetoptError as err:
print str(err)
print usage
sys.exit(2)
Expand Down
2 changes: 1 addition & 1 deletion printcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
try:
opts, args = getopt.getopt(sys.argv[1:], "b:svVh",
["baud=", "statusreport", "verbose", "version", "help"])
except getopt.GetoptError, err:
except getopt.GetoptError as err:
print str(err)
print usage
sys.exit(2)
Expand Down
2 changes: 1 addition & 1 deletion printrun/gcoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __getattr__(self, name):
import gcoder_line
Line = gcoder_line.GLine
LightLine = gcoder_line.GLightLine
except Exception, e:
except Exception as e:
logging.warning("Memory-efficient GCoder implementation unavailable: %s" % e)
Line = PyLine
LightLine = PyLightLine
Expand Down
6 changes: 3 additions & 3 deletions printrun/power/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def deinhibit_sleep():
return
inhibit_sleep_handler.UnInhibit(inhibit_sleep_token)
inhibit_sleep_token = None
except Exception, e:
except Exception as e:
logging.warning("Could not setup DBus for sleep inhibition: %s" % e)

def inhibit_sleep(reason):
Expand Down Expand Up @@ -107,7 +107,7 @@ def set_nice(nice, p = None):
set_nice(i, p)
high_priority_nice = i
break
except psutil.AccessDenied, e:
except psutil.AccessDenied as e:
pass
set_nice(orig_nice, p)

Expand All @@ -132,7 +132,7 @@ def powerset_print_start(reason):
def powerset_print_stop():
reset_priority()
deinhibit_sleep()
except ImportError, e:
except ImportError as e:
logging.warning("psutil unavailable, could not import power utils:" + str(e))

def powerset_print_start(reason):
Expand Down
2 changes: 1 addition & 1 deletion printrun/printcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ def pause(self):
# might be calling it from the thread itself
try:
self.print_thread.join()
except RuntimeError, e:
except RuntimeError as e:
if e.message == "cannot join current thread":
pass
else:
Expand Down
6 changes: 3 additions & 3 deletions printrun/pronsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ def set(self, var, str):
self.save_in_rc("set " + var, "set %s %s" % (var, value))
except AttributeError:
logging.debug(_("Unknown variable '%s'") % var)
except ValueError, ve:
except ValueError as ve:
if hasattr(ve, "from_validator"):
self.logError(_("Bad value %s for variable '%s': %s") % (str, var, ve.args[0]))
else:
Expand Down Expand Up @@ -675,7 +675,7 @@ def save_in_rc(self, key, definition):
# self.log("Saved '"+key+"' to '"+self.rc_filename+"'")
# else:
# self.log("Removed '"+key+"' from '"+self.rc_filename+"'")
except Exception, e:
except Exception as e:
self.logError("Saving failed for ", key + ":", str(e))
finally:
del rci, rco
Expand Down Expand Up @@ -962,7 +962,7 @@ def do_slice(self, l):
blocking = True)
self.log(_("Loading sliced file."))
self.do_load(l[0].replace(".stl", "_export.gcode"))
except Exception, e:
except Exception as e:
self.logError(_("Slicing failed: %s") % e)

def complete_slice(self, text, line, begidx, endidx):
Expand Down
10 changes: 5 additions & 5 deletions printrun/pronterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def __init__(self, app, filename = None, size = winsize):
rco = open("custombtn.txt", "w")
rco.write(_("# I moved all your custom buttons into .pronsolerc.\n# Please don't add them here any more.\n# Backup of your old buttons is in custombtn.old\n"))
rco.close()
except IOError, x:
except IOError as x:
logging.error(str(x))
else:
logging.warning(_("Note!!! You have specified custom buttons in both custombtn.txt and .pronsolerc"))
Expand Down Expand Up @@ -405,7 +405,7 @@ def do_settemp(self, l = ""):
self.logError(_("Printer is not online."))
else:
self.logError(_("You cannot set negative temperatures. To turn the hotend off entirely, set its temperature to 0."))
except Exception, x:
except Exception as x:
self.logError(_("You must enter a temperature. (%s)") % (repr(x),))

def do_bedtemp(self, l = ""):
Expand All @@ -425,7 +425,7 @@ def do_bedtemp(self, l = ""):
self.logError(_("Printer is not online."))
else:
self.logError(_("You cannot set negative temperatures. To turn the bed off entirely, set its temperature to 0."))
except Exception, x:
except Exception as x:
self.logError(_("You must enter a temperature. (%s)") % (repr(x),))

def do_setspeed(self, l = ""):
Expand All @@ -440,7 +440,7 @@ def do_setspeed(self, l = ""):
self.log(_("Setting print speed factor to %d%%.") % speed)
else:
self.logError(_("Printer is not online."))
except Exception, x:
except Exception as x:
self.logError(_("You must enter a speed. (%s)") % (repr(x),))

def do_setflow(self, l = ""):
Expand All @@ -455,7 +455,7 @@ def do_setflow(self, l = ""):
self.log(_("Setting print flow factor to %d%%.") % flow)
else:
self.logError(_("Printer is not online."))
except Exception, x:
except Exception as x:
self.logError(_("You must enter a flow. (%s)") % (repr(x),))

def setbedgui(self, f):
Expand Down
2 changes: 1 addition & 1 deletion printrun/serialWrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def set_special_baudrate(port, baudrate):

# set serial_struct
res = FCNTL.ioctl(port.fd, TCSETS2, buf)
except IOError, e:
except IOError as e:
raise ValueError('Failed to set custom baud rate (%s): %s' % (baudrate, e))

# We need to change the function inside the serialposix module otherwise, it won't
Expand Down
2 changes: 1 addition & 1 deletion printrun/stlplater.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ def autoplate(self, event = None):
if self.simarrange_path:
try:
self.autoplate_simarrange()
except Exception, e:
except Exception as e:
logging.warning(_("Failed to use simarrange for plating, "
"falling back to the standard method. "
"The error was: ") + e)
Expand Down
2 changes: 1 addition & 1 deletion pronsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

try:
opts, args = getopt.getopt(sys.argv[1:], "hVvc:e:", ["help", "version", "verbose", "conf=", "config=", "execute="])
except getopt.GetoptError, err:
except getopt.GetoptError as err:
print str(err)
print usage
sys.exit(2)
Expand Down
2 changes: 1 addition & 1 deletion pronterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

try:
opts, args = getopt.getopt(sys.argv[1:], "hVvac:e:", ["help", "version", "verbose", "autoconnect", "conf=", "config=", "execute="])
except getopt.GetoptError, err:
except getopt.GetoptError as err:
print str(err)
print usage
sys.exit(2)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from Cython.Build import cythonize
extensions = cythonize("printrun/gcoder_line.pyx")
from Cython.Distutils import build_ext
except ImportError, e:
except ImportError as e:
print "WARNING: Failed to cythonize: %s" % e
# Debug helper: uncomment these:
# import traceback
Expand Down

0 comments on commit fcb3027

Please sign in to comment.