- converted from Python2 code to Python3 code
- in camlib.py, CNCJob class -> generate_from_excellon_by_tool() was failing in the line to sort the tools due of been unable to compare between dict's. I replaced that section.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
|
||||
import sys
|
||||
import traceback
|
||||
import urllib
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
import getopt
|
||||
import random
|
||||
import logging
|
||||
@@ -16,7 +16,7 @@ import simplejson as json
|
||||
import re
|
||||
import webbrowser
|
||||
import os
|
||||
import Tkinter
|
||||
import tkinter
|
||||
from PyQt4 import QtCore
|
||||
import time # Just used for debugging. Double check before removing.
|
||||
from xml.dom.minidom import parseString as parse_xml_string
|
||||
@@ -54,11 +54,11 @@ class App(QtCore.QObject):
|
||||
try:
|
||||
cmd_line_options, args = getopt.getopt(sys.argv[1:], "h:", "shellfile=")
|
||||
except getopt.GetoptError:
|
||||
print cmd_line_help
|
||||
print(cmd_line_help)
|
||||
sys.exit(2)
|
||||
for opt, arg in cmd_line_options:
|
||||
if opt == '-h':
|
||||
print cmd_line_help
|
||||
print(cmd_line_help)
|
||||
sys.exit()
|
||||
elif opt == '--shellfile':
|
||||
cmd_line_shellfile = arg
|
||||
@@ -106,7 +106,7 @@ class App(QtCore.QObject):
|
||||
# Note: Setting the parameters to unicode does not seem
|
||||
# to have an effect. Then are received as Qstring
|
||||
# anyway.
|
||||
file_opened = QtCore.pyqtSignal(unicode, unicode) # File type and filename
|
||||
file_opened = QtCore.pyqtSignal(str, str) # File type and filename
|
||||
|
||||
progress = QtCore.pyqtSignal(int) # Percentage of progress
|
||||
|
||||
@@ -612,7 +612,7 @@ class App(QtCore.QObject):
|
||||
cmd_line_shellfile_text = myfile.read()
|
||||
self.shell._sysShell.exec_command(cmd_line_shellfile_text)
|
||||
except Exception as ext:
|
||||
print "ERROR: ", ext
|
||||
print(("ERROR: ", ext))
|
||||
sys.exit(2)
|
||||
|
||||
# Post-GUI initialization: Experimental attempt
|
||||
@@ -630,7 +630,7 @@ class App(QtCore.QObject):
|
||||
# because tcl was execudted in old instance of TCL
|
||||
pass
|
||||
else:
|
||||
self.tcl = Tkinter.Tcl()
|
||||
self.tcl = tkinter.Tcl()
|
||||
self.setup_shell()
|
||||
|
||||
def defaults_read_form(self):
|
||||
@@ -849,7 +849,7 @@ class App(QtCore.QObject):
|
||||
if result != 'None':
|
||||
self.shell.append_output(result + '\n')
|
||||
|
||||
except Tkinter.TclError, e:
|
||||
except tkinter.TclError as e:
|
||||
# This will display more precise answer if something in TCL shell fails
|
||||
result = self.tcl.eval("set errorInfo")
|
||||
self.log.error("Exec command Exception: %s" % (result + '\n'))
|
||||
@@ -895,7 +895,7 @@ class App(QtCore.QObject):
|
||||
if retval and retfcn(retval):
|
||||
self.shell.append_output(retfcn(retval) + "\n")
|
||||
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
#self.shell.append_error(''.join(traceback.format_exc()))
|
||||
#self.shell.append_error("?\n")
|
||||
self.shell.append_error(str(e) + "\n")
|
||||
@@ -915,14 +915,14 @@ class App(QtCore.QObject):
|
||||
if match:
|
||||
level = match.group(1)
|
||||
msg_ = match.group(2)
|
||||
self.ui.fcinfo.set_status(QtCore.QString(msg_), level=level)
|
||||
self.ui.fcinfo.set_status(str(msg_), level=level)
|
||||
|
||||
if toshell:
|
||||
error = level == "error" or level == "warning"
|
||||
self.shell_message(msg, error=error, show=True)
|
||||
|
||||
else:
|
||||
self.ui.fcinfo.set_status(QtCore.QString(msg), level="info")
|
||||
self.ui.fcinfo.set_status(str(msg), level="info")
|
||||
|
||||
if toshell:
|
||||
self.shell_message(msg)
|
||||
@@ -973,7 +973,7 @@ class App(QtCore.QObject):
|
||||
self.log.debug(" %s" % kind)
|
||||
self.log.debug(" %s" % filename)
|
||||
|
||||
record = {'kind': unicode(kind), 'filename': unicode(filename)}
|
||||
record = {'kind': str(kind), 'filename': str(filename)}
|
||||
if record in self.recent:
|
||||
return
|
||||
|
||||
@@ -1116,7 +1116,7 @@ class App(QtCore.QObject):
|
||||
layout1.addLayout(layout2)
|
||||
|
||||
logo = QtGui.QLabel()
|
||||
logo.setPixmap(QtGui.QPixmap('share:flatcam_icon256.png'))
|
||||
logo.setPixmap(QtGui.QPixmap('share/flatcam_icon256.png'))
|
||||
layout2.addWidget(logo, stretch=0)
|
||||
|
||||
title = QtGui.QLabel(
|
||||
@@ -1630,7 +1630,7 @@ class App(QtCore.QObject):
|
||||
|
||||
self.clipboard.setText(self.defaults["point_clipboard_format"] % (event.xdata, event.ydata))
|
||||
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
App.log.debug("Outside plot?")
|
||||
App.log.debug(str(e))
|
||||
|
||||
@@ -1700,7 +1700,7 @@ class App(QtCore.QObject):
|
||||
# The Qt methods above will return a QString which can cause problems later.
|
||||
# So far json.dump() will fail to serialize it.
|
||||
# TODO: Improve the serialization methods and remove this fix.
|
||||
filename = unicode(filename)
|
||||
filename = str(filename)
|
||||
|
||||
if filename == "":
|
||||
self.inform.emit("Open cancelled.")
|
||||
@@ -1727,7 +1727,7 @@ class App(QtCore.QObject):
|
||||
# The Qt methods above will return a QString which can cause problems later.
|
||||
# So far json.dump() will fail to serialize it.
|
||||
# TODO: Improve the serialization methods and remove this fix.
|
||||
filename = unicode(filename)
|
||||
filename = str(filename)
|
||||
|
||||
if filename == "":
|
||||
self.inform.emit("Open cancelled.")
|
||||
@@ -1754,7 +1754,7 @@ class App(QtCore.QObject):
|
||||
# The Qt methods above will return a QString which can cause problems later.
|
||||
# So far json.dump() will fail to serialize it.
|
||||
# TODO: Improve the serialization methods and remove this fix.
|
||||
filename = unicode(filename)
|
||||
filename = str(filename)
|
||||
|
||||
if filename == "":
|
||||
self.inform.emit("Open cancelled.")
|
||||
@@ -1781,7 +1781,7 @@ class App(QtCore.QObject):
|
||||
# The Qt methods above will return a QString which can cause problems later.
|
||||
# So far json.dump() will fail to serialize it.
|
||||
# TODO: Improve the serialization methods and remove this fix.
|
||||
filename = unicode(filename)
|
||||
filename = str(filename)
|
||||
|
||||
if filename == "":
|
||||
self.inform.emit("Open cancelled.")
|
||||
@@ -1831,7 +1831,7 @@ class App(QtCore.QObject):
|
||||
except TypeError:
|
||||
filename = QtGui.QFileDialog.getSaveFileName(caption="Export SVG")
|
||||
|
||||
filename = unicode(filename)
|
||||
filename = str(filename)
|
||||
|
||||
if filename == "":
|
||||
self.inform.emit("Export SVG cancelled.")
|
||||
@@ -1854,7 +1854,7 @@ class App(QtCore.QObject):
|
||||
except TypeError:
|
||||
filename = QtGui.QFileDialog.getOpenFileName(caption="Import SVG")
|
||||
|
||||
filename = unicode(filename)
|
||||
filename = str(filename)
|
||||
|
||||
if filename == "":
|
||||
self.inform.emit("Open cancelled.")
|
||||
@@ -1897,7 +1897,7 @@ class App(QtCore.QObject):
|
||||
except TypeError:
|
||||
filename = QtGui.QFileDialog.getSaveFileName(caption="Save Project As ...")
|
||||
|
||||
filename = unicode(filename)
|
||||
filename = str(filename)
|
||||
|
||||
try:
|
||||
f = open(filename, 'r')
|
||||
@@ -2031,7 +2031,7 @@ class App(QtCore.QObject):
|
||||
app_obj.progress.emit(0)
|
||||
raise IOError('Failed to open file: ' + filename)
|
||||
|
||||
except ParseError, e:
|
||||
except ParseError as e:
|
||||
app_obj.inform.emit("[error] Failed to parse file: " + filename + ". " + e[0])
|
||||
app_obj.progress.emit(0)
|
||||
self.log.error(str(e))
|
||||
@@ -2332,7 +2332,7 @@ class App(QtCore.QObject):
|
||||
self.worker_task.emit({'fcn': worker_task, 'params': [self]})
|
||||
|
||||
def register_folder(self, filename):
|
||||
self.defaults["last_folder"] = os.path.split(unicode(filename))[0]
|
||||
self.defaults["last_folder"] = os.path.split(str(filename))[0]
|
||||
|
||||
def set_progress_bar(self, percentage, text=""):
|
||||
self.ui.progress_bar.setValue(int(percentage))
|
||||
@@ -3584,7 +3584,7 @@ class App(QtCore.QObject):
|
||||
output = ''
|
||||
import collections
|
||||
od = collections.OrderedDict(sorted(commands.items()))
|
||||
for cmd_, val in od.iteritems():
|
||||
for cmd_, val in list(od.items()):
|
||||
#print cmd, '\n', ''.join(['~']*len(cmd))
|
||||
output += cmd_ + ' \n' + ''.join(['~'] * len(cmd_)) + '\n'
|
||||
|
||||
@@ -3638,7 +3638,7 @@ class App(QtCore.QObject):
|
||||
|
||||
try:
|
||||
obj.follow(**kwa)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return "ERROR: %s" % str(e)
|
||||
|
||||
# def get_sys(param):
|
||||
@@ -4132,11 +4132,11 @@ class App(QtCore.QObject):
|
||||
|
||||
# TODO: Move this to constructor
|
||||
icons = {
|
||||
"gerber": "share:flatcam_icon16.png",
|
||||
"excellon": "share:drill16.png",
|
||||
"cncjob": "share:cnc16.png",
|
||||
"project": "share:project16.png",
|
||||
"svg": "share:geometry16.png"
|
||||
"gerber": "share/flatcam_icon16.png",
|
||||
"excellon": "share/drill16.png",
|
||||
"cncjob": "share/cnc16.png",
|
||||
"project": "share/project16.png",
|
||||
"svg": "share/geometry16.png"
|
||||
}
|
||||
|
||||
openers = {
|
||||
@@ -4225,12 +4225,12 @@ class App(QtCore.QObject):
|
||||
"?s=" + str(self.defaults['serial']) + \
|
||||
"&v=" + str(self.version) + \
|
||||
"&os=" + str(self.os) + \
|
||||
"&" + urllib.urlencode(self.defaults["stats"])
|
||||
"&" + urllib.parse.urlencode(self.defaults["stats"])
|
||||
App.log.debug("Checking for updates @ %s" % full_url)
|
||||
|
||||
### Get the data
|
||||
try:
|
||||
f = urllib.urlopen(full_url)
|
||||
f = urllib.request.urlopen(full_url)
|
||||
except:
|
||||
# App.log.warning("Failed checking for latest version. Could not connect.")
|
||||
self.log.warning("Failed checking for latest version. Could not connect.")
|
||||
@@ -4239,7 +4239,7 @@ class App(QtCore.QObject):
|
||||
|
||||
try:
|
||||
data = json.load(f)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
App.log.error("Could not parse information about latest version.")
|
||||
self.inform.emit("[error] Could not parse information about latest version.")
|
||||
App.log.debug("json.load(): %s" % str(e))
|
||||
@@ -4257,7 +4257,7 @@ class App(QtCore.QObject):
|
||||
App.log.debug("Newer version available.")
|
||||
self.message.emit(
|
||||
"Newer Version Available",
|
||||
QtCore.QString("There is a newer version of FlatCAM " +
|
||||
str("There is a newer version of FlatCAM " +
|
||||
"available for download:<br><br>" +
|
||||
"<B>" + data["name"] + "</b><br>" +
|
||||
data["message"].replace("\n", "<br>")),
|
||||
|
||||
Reference in New Issue
Block a user