- 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:
Marius Stanciu
2018-05-26 04:43:40 +03:00
parent bb3b07455c
commit a4bbb98bf1
76 changed files with 394 additions and 389 deletions

View File

@@ -97,7 +97,7 @@ class TclCommand(object):
command_string = []
for arg_key, arg_type in self.help['args'].items():
for arg_key, arg_type in list(self.help['args'].items()):
command_string.append(get_decorated_argument(arg_key, arg_type, True))
return "> " + alias_name + " " + " ".join(command_string)
@@ -147,7 +147,7 @@ class TclCommand(object):
for alias in self.aliases:
help_string.append(get_decorated_command(alias))
for key, value in self.help['args'].items():
for key, value in list(self.help['args'].items()):
help_string.append(get_decorated_argument(key, value))
# timeout is unique for signaled commands (this is not best oop practice, but much easier for now)
@@ -206,13 +206,13 @@ class TclCommand(object):
# check arguments
idx = 0
arg_names_items = self.arg_names.items()
arg_names_items = list(self.arg_names.items())
for argument in arguments:
if len(self.arg_names) > idx:
key, arg_type = arg_names_items[idx]
try:
named_args[key] = arg_type(argument)
except Exception, e:
except Exception as e:
self.raise_tcl_error("Cannot cast named argument '%s' to type %s with exception '%s'."
% (key, arg_type, str(e)))
else:
@@ -228,7 +228,7 @@ class TclCommand(object):
named_args[key] = self.option_types[key](options[key])
else:
named_args[key] = int(options[key])
except Exception, e:
except Exception as e:
self.raise_tcl_error("Cannot cast argument '-%s' to type '%s' with exception '%s'."
% (key, self.option_types[key], str(e)))
@@ -292,7 +292,7 @@ class TclCommandSignaled(TclCommand):
"""
!!! I left it here only for demonstration !!!
Go to TclCommandCncjob and into class definition put
class TclCommandCncjob(TclCommand.TclCommandSignaled):
class TclCommandCncjob(TclCommandSignaled):
also change
obj.generatecncjob(use_thread = False, **args)
to

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommand
class TclCommandAddCircle(TclCommand.TclCommand):
class TclCommandAddCircle(TclCommand):
"""
Tcl shell command to creates a circle in the given Geometry object.

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommandSignaled
class TclCommandAddPolygon(TclCommand.TclCommandSignaled):
class TclCommandAddPolygon(TclCommandSignaled):
"""
Tcl shell command to create a polygon in the given Geometry object
"""

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommandSignaled
class TclCommandAddPolyline(TclCommand.TclCommandSignaled):
class TclCommandAddPolyline(TclCommandSignaled):
"""
Tcl shell command to create a polyline in the given Geometry object
"""

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommandSignaled
class TclCommandAddRectangle(TclCommand.TclCommandSignaled):
class TclCommandAddRectangle(TclCommandSignaled):
"""
Tcl shell command to add a rectange to the given Geometry object.
"""

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommandSignaled
class TclCommandAlignDrill(TclCommand.TclCommandSignaled):
class TclCommandAlignDrill(TclCommandSignaled):
"""
Tcl shell command to create excellon with drills for aligment.
"""
@@ -180,7 +180,7 @@ class TclCommandAlignDrill(TclCommand.TclCommandSignaled):
name + "_aligndrill",
alligndrill_init_me)
except Exception, e:
except Exception as e:
return "Operation failed: %s" % str(e)
else:
@@ -195,7 +195,7 @@ class TclCommandAlignDrill(TclCommand.TclCommandSignaled):
px = dist
py = dist
obj.app.new_object("excellon", name + "_alligndrill", alligndrill_init_me)
except Exception, e:
except Exception as e:
return "Operation failed: %s" % str(e)
return 'Ok'

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommandSignaled
class TclCommandAlignDrillGrid(TclCommand.TclCommandSignaled):
class TclCommandAlignDrillGrid(TclCommandSignaled):
"""
Tcl shell command to create an Excellon object
with drills for aligment grid.

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommandSignaled
class TclCommandCncjob(TclCommand.TclCommandSignaled):
class TclCommandCncjob(TclCommandSignaled):
"""
Tcl shell command to Generates a CNC Job from a Geometry Object.

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommand
class TclCommandCutout(TclCommand.TclCommand):
class TclCommandCutout(TclCommand):
"""
Tcl shell command to create a board cutout geometry.
@@ -95,5 +95,5 @@ class TclCommandCutout(TclCommand.TclCommand):
try:
obj.app.new_object("geometry", name + "_cutout", geo_init_me)
except Exception, e:
except Exception as e:
return "Operation failed: %s" % str(e)

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommand
class TclCommandDelete(TclCommand.TclCommand):
class TclCommandDelete(TclCommand):
"""
Tcl shell command to delete an object.

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommandSignaled
class TclCommandDrillcncjob(TclCommand.TclCommandSignaled):
class TclCommandDrillcncjob(TclCommandSignaled):
"""
Tcl shell command to Generates a Drill CNC Job from a Excellon Object.
"""

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommandSignaled
class TclCommandExportGcode(TclCommand.TclCommandSignaled):
class TclCommandExportGcode(TclCommandSignaled):
"""
Tcl shell command to export gcode as tcl output for "set X [export_gcode ...]"

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommand
class TclCommandExportSVG(TclCommand.TclCommand):
class TclCommandExportSVG(TclCommand):
"""
Tcl shell command to export a Geometry Object as an SVG File.

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommandSignaled
class TclCommandExteriors(TclCommand.TclCommandSignaled):
class TclCommandExteriors(TclCommandSignaled):
"""
Tcl shell command to get exteriors of polygons
"""

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommandSignaled
class TclCommandGeoCutout(TclCommand.TclCommandSignaled):
class TclCommandGeoCutout(TclCommandSignaled):
"""
Tcl shell command to cut holding gaps from geometry.
"""

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommand
class TclCommandGeoUnion(TclCommand.TclCommand):
class TclCommandGeoUnion(TclCommand):
"""
Tcl shell command to run a union (addition) operation on the
components of a geometry object.

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommand
class TclCommandGetNames(TclCommand.TclCommand):
class TclCommandGetNames(TclCommand):
"""
Tcl shell command to set an object as active in the GUI.

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommand
class TclCommandGetSys(TclCommand.TclCommand):
class TclCommandGetSys(TclCommand):
"""
Tcl shell command to get the value of a system variable

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommandSignaled
class TclCommandImportSvg(TclCommand.TclCommandSignaled):
class TclCommandImportSvg(TclCommandSignaled):
"""
Tcl shell command to import an SVG file as a Geometry Object.
"""

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommandSignaled
class TclCommandInteriors(TclCommand.TclCommandSignaled):
class TclCommandInteriors(TclCommandSignaled):
"""
Tcl shell command to get interiors of polygons
"""

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommandSignaled
class TclCommandIsolate(TclCommand.TclCommandSignaled):
class TclCommandIsolate(TclCommandSignaled):
"""
Tcl shell command to Creates isolation routing geometry for the given Gerber.

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommand
class TclCommandJoinExcellon(TclCommand.TclCommand):
class TclCommandJoinExcellon(TclCommand):
"""
Tcl shell command to merge Excellon objects.

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommand
class TclCommandJoinGeometry(TclCommand.TclCommand):
class TclCommandJoinGeometry(TclCommand):
"""
Tcl shell command to merge Excellon objects.

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommandSignaled
class TclCommandMillHoles(TclCommand.TclCommandSignaled):
class TclCommandMillHoles(TclCommandSignaled):
"""
Tcl shell command to Create Geometry Object for milling holes from Excellon.

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommandSignaled
class TclCommandMirror(TclCommand.TclCommandSignaled):
class TclCommandMirror(TclCommandSignaled):
"""
Tcl shell command to mirror an object.
"""
@@ -90,7 +90,7 @@ class TclCommandMirror(TclCommand.TclCommandSignaled):
obj.mirror(axis, [px, py])
obj.plot()
except Exception, e:
except Exception as e:
return "Operation failed: %s" % str(e)
else:
@@ -104,5 +104,5 @@ class TclCommandMirror(TclCommand.TclCommandSignaled):
try:
obj.mirror(axis, [dist, dist])
obj.plot()
except Exception, e:
except Exception as e:
return "Operation failed: %s" % str(e)

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommand
class TclCommandNew(TclCommand.TclCommand):
class TclCommandNew(TclCommand):
"""
Tcl shell command to starts a new project. Clears objects from memory
"""

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommandSignaled
class TclCommandNewGeometry(TclCommand.TclCommandSignaled):
class TclCommandNewGeometry(TclCommandSignaled):
"""
Tcl shell command to subtract polygon from the given Geometry object.
"""

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommand
class TclCommandOffset(TclCommand.TclCommand):
class TclCommandOffset(TclCommand):
"""
Tcl shell command to change the position of the object.

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommandSignaled
class TclCommandOpenExcellon(TclCommand.TclCommandSignaled):
class TclCommandOpenExcellon(TclCommandSignaled):
"""
Tcl shell command to open an Excellon file.
"""

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommandSignaled
class TclCommandOpenGCode(TclCommand.TclCommandSignaled):
class TclCommandOpenGCode(TclCommandSignaled):
"""
Tcl shell command to open a G-Code file.
"""

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommandSignaled
class TclCommandOpenGerber(TclCommand.TclCommandSignaled):
class TclCommandOpenGerber(TclCommandSignaled):
"""
Tcl shell command to opens a Gerber file
"""
@@ -61,7 +61,7 @@ class TclCommandOpenGerber(TclCommand.TclCommandSignaled):
app_obj.progress.emit(0)
self.raise_tcl_error('Failed to open file: %s' % filename)
except ParseError, e:
except ParseError as e:
app_obj.inform.emit("[error] Failed to parse file: %s, %s " % (filename, str(e)))
app_obj.progress.emit(0)
self.log.error(str(e))

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommandSignaled
class TclCommandOpenProject(TclCommand.TclCommandSignaled):
class TclCommandOpenProject(TclCommandSignaled):
"""
Tcl shell command to open a FlatCAM project.
"""

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommandSignaled
class TclCommandOptions(TclCommand.TclCommandSignaled):
class TclCommandOptions(TclCommandSignaled):
"""
Tcl shell command to open an Excellon file.
"""

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommandSignaled
class TclCommandPaint(TclCommand.TclCommandSignaled):
class TclCommandPaint(TclCommandSignaled):
"""
Paint the interior of polygons
"""

View File

@@ -1,10 +1,10 @@
from ObjectCollection import *
from copy import copy,deepcopy
import TclCommand
from tclCommands.TclCommand import TclCommand
class TclCommandPanelize(TclCommand.TclCommand):
class TclCommandPanelize(TclCommand):
"""
Tcl shell command to pannelize an object.

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommand
class TclCommandPlot(TclCommand.TclCommand):
class TclCommandPlot(TclCommand):
"""
Tcl shell command to update the plot on the user interface.

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommandSignaled
class TclCommandSaveProject(TclCommand.TclCommandSignaled):
class TclCommandSaveProject(TclCommandSignaled):
"""
Tcl shell command to save the FlatCAM project to file.
"""

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommand
class TclCommandScale(TclCommand.TclCommand):
class TclCommandScale(TclCommand):
"""
Tcl shell command to resizes the object by a factor.

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommand
class TclCommandSetActive(TclCommand.TclCommand):
class TclCommandSetActive(TclCommand):
"""
Tcl shell command to set an object as active in the GUI.

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommand
class TclCommandSetSys(TclCommand.TclCommand):
class TclCommandSetSys(TclCommand):
"""
Tcl shell command to set the value of a system variable

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommandSignaled
class TclCommandSubtractPoly(TclCommand.TclCommandSignaled):
class TclCommandSubtractPoly(TclCommandSignaled):
"""
Tcl shell command to create a new empty Geometry object.
"""

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommandSignaled
class TclCommandSubtractRectangle(TclCommand.TclCommandSignaled):
class TclCommandSubtractRectangle(TclCommandSignaled):
"""
Tcl shell command to subtract a rectange from the given Geometry object.
"""

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommand
class TclCommandVersion(TclCommand.TclCommand):
class TclCommandVersion(TclCommand):
"""
Tcl shell command to check the program version.

View File

@@ -1,8 +1,8 @@
from ObjectCollection import *
import TclCommand
from tclCommands.TclCommand import TclCommandSignaled
class TclCommandWriteGCode(TclCommand.TclCommandSignaled):
class TclCommandWriteGCode(TclCommandSignaled):
"""
Tcl shell command to save the G-code of a CNC Job object to file.
"""

View File

@@ -72,9 +72,9 @@ def register_all_commands(app, commands):
:return: None
"""
tcl_modules = {k: v for k, v in sys.modules.items() if k.startswith('tclCommands.TclCommand')}
tcl_modules = {k: v for k, v in list(sys.modules.items()) if k.startswith('tclCommands.TclCommand')}
for key, mod in tcl_modules.items():
for key, mod in list(tcl_modules.items()):
if key != 'tclCommands.TclCommand':
class_name = key.split('.')[1]
class_type = getattr(mod, class_name)