- fixed some issues with error reporting for the Tcl commands

- fixed drillcncjob Tcl command crashing the app when the used name is wrong and therefore no Excellon objects are located
This commit is contained in:
Marius Stanciu
2021-06-10 14:25:20 +03:00
committed by Marius
parent 8cd5d253be
commit 8a01a0b04b
3 changed files with 25 additions and 8 deletions

View File

@@ -7,6 +7,11 @@ CHANGELOG for FlatCAM beta
================================================= =================================================
10.06.2021
- fixed some issues with error reporting for the Tcl commands
- fixed drillcncjob Tcl command crashing the app when the used name is wrong and therefore no Excellon objects are located
16.05.2021 16.05.2021
- fixed SVG import to show an error for SVG files that have SVG units not mm or cm or inch - fixed SVG import to show an error for SVG files that have SVG units not mm or cm or inch

View File

@@ -294,6 +294,9 @@ class TermWidget(QWidget):
class FCShell(TermWidget): class FCShell(TermWidget):
tcl_error_signal = QtCore.pyqtSignal(object, object)
def __init__(self, app, version, *args): def __init__(self, app, version, *args):
""" """
Initialize the TCL Shell. A dock widget that holds the GUI interface to the FlatCAM command line. Initialize the TCL Shell. A dock widget that holds the GUI interface to the FlatCAM command line.
@@ -339,6 +342,9 @@ class FCShell(TermWidget):
self.app.inform_shell[str].connect(self.app.info_shell) self.app.inform_shell[str].connect(self.app.info_shell)
self.app.inform_shell[str, bool].connect(self.app.info_shell) self.app.inform_shell[str, bool].connect(self.app.info_shell)
# used to signal that an error happened in the TCL
self.tcl_error_signal.connect(self.display_tcl_error)
self._browser.find_text = self.find_text self._browser.find_text = self.find_text
self._edit.on_escape_key = self.on_escape_key self._edit.on_escape_key = self.on_escape_key
@@ -551,7 +557,8 @@ class FCShell(TermWidget):
:return: raise exception :return: raise exception
""" """
self.display_tcl_error(text) # self.display_tcl_error(text)
self.tcl_error_signal.emit(text, None)
# raise self.TclErrorException(text) # raise self.TclErrorException(text)
class TclErrorException(Exception): class TclErrorException(Exception):

View File

@@ -123,14 +123,14 @@ class TclCommandDrillcncjob(TclCommandSignaled):
if obj is None: if obj is None:
if muted is False: if muted is False:
self.raise_tcl_error("Object not found: %s" % name) self.raise_tcl_error("Object not found: %s" % name)
else:
return "fail" return "Object not found: %s" % name
if obj.kind != 'excellon': if obj.kind != 'excellon':
if muted is False: if muted is False:
self.raise_tcl_error('Expected ExcellonObject, got %s %s.' % (name, type(obj))) self.raise_tcl_error('Expected ExcellonObject, got %s %s.' % (name, type(obj)))
else:
return "fail" return 'Expected ExcellonObject, got %s %s.' % (name, type(obj))
xmin = obj.options['xmin'] xmin = obj.options['xmin']
ymin = obj.options['ymin'] ymin = obj.options['ymin']
@@ -169,7 +169,8 @@ class TclCommandDrillcncjob(TclCommandSignaled):
self.raise_tcl_error("One or more tool diameters of the drills to be drilled passed to the " self.raise_tcl_error("One or more tool diameters of the drills to be drilled passed to the "
"TclCommand are not actual tool diameters in the Excellon object.") "TclCommand are not actual tool diameters in the Excellon object.")
else: else:
return "fail" return "One or more tool diameters of the drills to be drilled passed to the "\
"TclCommand are not actual tool diameters in the Excellon object."
# make a string of diameters separated by comma; this is what generate_from_excellon_by_tool() is # make a string of diameters separated by comma; this is what generate_from_excellon_by_tool() is
# expecting as tools parameter # expecting as tools parameter
@@ -189,8 +190,8 @@ class TclCommandDrillcncjob(TclCommandSignaled):
if muted is False: if muted is False:
self.raise_tcl_error("Bad tools: %s" % str(e)) self.raise_tcl_error("Bad tools: %s" % str(e))
else:
return "fail" return "Bad tools: %s" % str(e)
used_tools_info = [] used_tools_info = []
used_tools_info.insert(0, [_("Tool_nr"), _("Diameter"), _("Drills_Nr"), _("Slots_Nr")]) used_tools_info.insert(0, [_("Tool_nr"), _("Diameter"), _("Drills_Nr"), _("Slots_Nr")])
@@ -242,6 +243,8 @@ class TclCommandDrillcncjob(TclCommandSignaled):
if len(eval(xy_toolchange)) != 2: if len(eval(xy_toolchange)) != 2:
self.raise_tcl_error("The entered value for 'toolchangexy' needs to have the format x,y or " self.raise_tcl_error("The entered value for 'toolchangexy' needs to have the format x,y or "
"in format (x, y) - no spaces allowed. But always two comma separated values.") "in format (x, y) - no spaces allowed. But always two comma separated values.")
return "The entered value for 'toolchangexy' needs to have the format x,y or "\
"in format (x, y) - no spaces allowed. But always two comma separated values."
endz = args["endz"] if "endz" in args and args["endz"] is not None else \ endz = args["endz"] if "endz" in args and args["endz"] is not None else \
self.app.defaults["tools_drill_endz"] self.app.defaults["tools_drill_endz"]
@@ -257,6 +260,8 @@ class TclCommandDrillcncjob(TclCommandSignaled):
if len(eval(xy_end)) != 2: if len(eval(xy_end)) != 2:
self.raise_tcl_error("The entered value for 'xy_end' needs to have the format x,y or " self.raise_tcl_error("The entered value for 'xy_end' needs to have the format x,y or "
"in format (x, y) - no spaces allowed. But always two comma separated values.") "in format (x, y) - no spaces allowed. But always two comma separated values.")
return "The entered value for 'xy_end' needs to have the format x,y or "\
"in format (x, y) - no spaces allowed. But always two comma separated values."
opt_type = args["opt_type"] if "opt_type" in args and args["opt_type"] else 'B' opt_type = args["opt_type"] if "opt_type" in args and args["opt_type"] else 'B'