From 8a01a0b04b86757e5fa3093b2879ff301b6c15c8 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Thu, 10 Jun 2021 14:25:20 +0300 Subject: [PATCH] - 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 --- CHANGELOG.md | 5 +++++ appPlugins/ToolShell.py | 9 ++++++++- tclCommands/TclCommandDrillcncjob.py | 19 ++++++++++++------- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cfdf7bcf..352be26e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 - fixed SVG import to show an error for SVG files that have SVG units not mm or cm or inch diff --git a/appPlugins/ToolShell.py b/appPlugins/ToolShell.py index 4e3c5ded..091715d6 100644 --- a/appPlugins/ToolShell.py +++ b/appPlugins/ToolShell.py @@ -294,6 +294,9 @@ class TermWidget(QWidget): class FCShell(TermWidget): + + tcl_error_signal = QtCore.pyqtSignal(object, object) + def __init__(self, app, version, *args): """ 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, 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._edit.on_escape_key = self.on_escape_key @@ -551,7 +557,8 @@ class FCShell(TermWidget): :return: raise exception """ - self.display_tcl_error(text) + # self.display_tcl_error(text) + self.tcl_error_signal.emit(text, None) # raise self.TclErrorException(text) class TclErrorException(Exception): diff --git a/tclCommands/TclCommandDrillcncjob.py b/tclCommands/TclCommandDrillcncjob.py index 558077b2..43717caf 100644 --- a/tclCommands/TclCommandDrillcncjob.py +++ b/tclCommands/TclCommandDrillcncjob.py @@ -123,14 +123,14 @@ class TclCommandDrillcncjob(TclCommandSignaled): if obj is None: if muted is False: self.raise_tcl_error("Object not found: %s" % name) - else: - return "fail" + + return "Object not found: %s" % name if obj.kind != 'excellon': if muted is False: 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'] 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 " "TclCommand are not actual tool diameters in the Excellon object.") 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 # expecting as tools parameter @@ -189,8 +190,8 @@ class TclCommandDrillcncjob(TclCommandSignaled): if muted is False: self.raise_tcl_error("Bad tools: %s" % str(e)) - else: - return "fail" + + return "Bad tools: %s" % str(e) used_tools_info = [] 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: 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.") + 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 \ self.app.defaults["tools_drill_endz"] @@ -257,6 +260,8 @@ class TclCommandDrillcncjob(TclCommandSignaled): if len(eval(xy_end)) != 2: 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.") + 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'