From 54def9a426c12c09b85694596992ac5a534d9ba2 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sat, 29 Jan 2022 16:24:29 +0200 Subject: [PATCH] - in the `panelize`, `cutout` and `geocutout` Tcl commands updated the error strings and made sure that if an error occur then a potential script execution in chain is aborted --- CHANGELOG.md | 1 + app_Main.py | 4 ++-- tclCommands/TclCommandCutout.py | 9 +++++---- tclCommands/TclCommandGeoCutout.py | 13 +++++++------ tclCommands/TclCommandPanelize.py | 12 ++++++++---- 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f5ddab13..a6c3c6a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ CHANGELOG for FlatCAM beta - upgraded/fixed the Panelize Tcl command - added a new preprocessor for Marlin that has movemements on the Z axis named `Marlin_laser_Z` - cleaned up Marlin preprocessors +- in the `panelize`, `cutout` and `geocutout` Tcl commands updated the error strings and made sure that if an error occur then a potential script execution in chain is aborted 28.01.2022 diff --git a/app_Main.py b/app_Main.py index 69b2a6ed..0b76083b 100644 --- a/app_Main.py +++ b/app_Main.py @@ -11395,7 +11395,7 @@ class MenuFileHandlers(QtCore.QObject): self.log.debug("open_gerber()") if not os.path.exists(filename): - self.inform.emit('[ERROR_NOTCL] %s' % _("File no longer available.")) + self.inform.emit('[ERROR_NOTCL] %s. %s' % (filename, _("File no longer available."))) return with self.app.proc_container.new('%s...' % _("Opening")): @@ -11433,7 +11433,7 @@ class MenuFileHandlers(QtCore.QObject): self.log.debug("open_excellon()") if not os.path.exists(filename): - self.inform.emit('[ERROR_NOTCL] %s' % _("File no longer available.")) + self.inform.emit('[ERROR_NOTCL] %s. %s' % (filename, _("File no longer available."))) return # How the object should be initialized diff --git a/tclCommands/TclCommandCutout.py b/tclCommands/TclCommandCutout.py index e891e274..d01ee010 100644 --- a/tclCommands/TclCommandCutout.py +++ b/tclCommands/TclCommandCutout.py @@ -67,8 +67,8 @@ class TclCommandCutout(TclCommand): name = args['name'] else: self.app.inform.emit( - "[WARNING]The name of the object for which cutout is done is missing. Add it and retry.") - return + "[WARNING] The name of the object for which cutout is done is missing. Add it and retry.") + return "fail" if 'margin' in args: margin_par = float(args['margin']) @@ -102,8 +102,9 @@ class TclCommandCutout(TclCommand): try: obj = self.app.collection.get_by_name(str(name)) except Exception as e: - log.error("TclCommandCutout.execute() --> %s" % str(e)) - return "Could not retrieve object: %s" % name + self.app.log.error("TclCommandCutout.execute(). Missing object: --> %s" % str(e)) + self.app.log.debug("Could not retrieve object: %s" % name) + return "fail" def geo_init_me(geo_obj, app_obj): geo_obj.multigeo = False diff --git a/tclCommands/TclCommandGeoCutout.py b/tclCommands/TclCommandGeoCutout.py index aacecd4b..3296df36 100644 --- a/tclCommands/TclCommandGeoCutout.py +++ b/tclCommands/TclCommandGeoCutout.py @@ -145,7 +145,7 @@ class TclCommandGeoCutout(TclCommandSignaled): else: self.app.inform.emit( "[WARNING] %s" % _("The name of the object for which cutout is done is missing. Add it and retry.")) - return + return "fail" if 'margin' in args: margin = float(args['margin']) @@ -177,17 +177,18 @@ class TclCommandGeoCutout(TclCommandSignaled): cutout_obj = self.app.collection.get_by_name(str(name)) except Exception as e: self.app.log.error("TclCommandGeoCutout.execute() --> %s" % str(e)) - return "Could not retrieve object: %s" % name + self.app.log.error("Could not retrieve object: %s" % name) + return "fail" if 0 in {dia}: self.app.inform.emit( "[WARNING] %s" % _("Tool Diameter is zero value. Change it to a positive real number.")) - return "Tool Diameter is zero value. Change it to a positive real number." + return "fail" if gaps not in ['lr', 'tb', '2lr', '2tb', '4', '8', 4, 8]: self.app.inform.emit( "[WARNING] %s" % _("Gaps value can be only one of: 'lr', 'tb', '2lr', '2tb', 4 or 8.")) - return + return "fail" # Get min and max data for each object as we just cut rectangles across X or Y xmin, ymin, xmax, ymax = cutout_obj.bounds() @@ -308,7 +309,7 @@ class TclCommandGeoCutout(TclCommandSignaled): try: geo = cutout_obj.isolation_geometry((dia / 2), iso_type=0, corner=2) except Exception as exc: - log.error("TclCommandGeoCutout.execute() --> %s" % str(exc)) + self.app.log.error("TclCommandGeoCutout.execute() --> %s" % str(exc)) return 'fail' if gaps_u == 8 or gaps_u == '2lr': @@ -360,4 +361,4 @@ class TclCommandGeoCutout(TclCommandSignaled): cutout_obj = self.app.collection.get_by_name(outname) else: self.app.inform.emit("[ERROR] %s" % _("Cancelled. Object type is not supported.")) - return + return "fail" diff --git a/tclCommands/TclCommandPanelize.py b/tclCommands/TclCommandPanelize.py index 671a5f78..5e98109d 100644 --- a/tclCommands/TclCommandPanelize.py +++ b/tclCommands/TclCommandPanelize.py @@ -89,17 +89,20 @@ class TclCommandPanelize(TclCommand): try: obj = self.app.collection.get_by_name(str(name)) except Exception: - return "Could not retrieve object: %s" % name + self.app.log.error("Could not retrieve object: %s" % name) + return "fail" if obj is None: - return "Object not found: %s" % name + self.app.log.error("Object not found: %s" % name) + return "fail" if 'box' in args: boxname = args['box'] try: box = self.app.collection.get_by_name(boxname) except Exception: - return "Could not retrieve object: %s" % name + self.app.log.error("Could not retrieve object: %s" % name) + return "fail" else: box = obj @@ -114,7 +117,8 @@ class TclCommandPanelize(TclCommand): rows = int(0) if 'columns' not in args and 'rows' not in args: - return "ERROR: Specify either -columns or -rows. The one not specified it will assumed to be 0" + self.app.log.error("ERROR: Specify either -columns or -rows. The one not specified it will assumed to be 0") + return "fail" if 'outname' in args: outname = args['outname']