From 0a9adcb82d41f4cfe0e680b7764f355dedd1d04d Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Mon, 17 Jan 2022 12:57:28 +0200 Subject: [PATCH] - made sure that in Tcl commands deleting argument keys will not raise an error --- CHANGELOG.md | 1 + tclCommands/TclCommand.py | 2 +- tclCommands/TclCommandBbox.py | 2 +- tclCommands/TclCommandCncjob.py | 2 +- tclCommands/TclCommandExportGcode.py | 2 +- tclCommands/TclCommandFollow.py | 2 +- tclCommands/TclCommandIsolate.py | 2 +- tclCommands/TclCommandMillDrills.py | 8 +++----- tclCommands/TclCommandMillSlots.py | 14 +++----------- tclCommands/TclCommandNregions.py | 2 +- 10 files changed, 14 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b34fcef4..5a03c436 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ CHANGELOG for FlatCAM beta 17.01.2022 - fixed issues in the 'millslots' and 'milldrills' Tcl commands for the case when some parameters are not used +- made sure that in Tcl commands deleting argument keys will not raise an error 15.01.2022 diff --git a/tclCommands/TclCommand.py b/tclCommands/TclCommand.py index 9453d382..68904b02 100644 --- a/tclCommands/TclCommand.py +++ b/tclCommands/TclCommand.py @@ -409,7 +409,7 @@ class TclCommandSignaled(TclCommand): args, unnamed_args = self.check_args(args) if 'timeout' in args: passed_timeout = args['timeout'] - del args['timeout'] + args.pop('timeout', None) else: passed_timeout = self.app.defaults['global_background_timeout'] diff --git a/tclCommands/TclCommandBbox.py b/tclCommands/TclCommandBbox.py index b976023d..34dfec3f 100644 --- a/tclCommands/TclCommandBbox.py +++ b/tclCommands/TclCommandBbox.py @@ -87,7 +87,7 @@ class TclCommandBbox(TclCommand): else: rounded = bool(eval(self.app.defaults["gerber_bboxrounded"])) - del args['name'] + args.pop('name', None) try: def geo_init(geo_obj, app_obj): diff --git a/tclCommands/TclCommandCncjob.py b/tclCommands/TclCommandCncjob.py index a8f637cf..2d7836c0 100644 --- a/tclCommands/TclCommandCncjob.py +++ b/tclCommands/TclCommandCncjob.py @@ -211,7 +211,7 @@ class TclCommandCncjob(TclCommandSignaled): 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.") - del args['name'] + args.pop('name', None) for arg in args: if arg == "toolchange_xy" or arg == "spindlespeed" or arg == "startz": diff --git a/tclCommands/TclCommandExportGcode.py b/tclCommands/TclCommandExportGcode.py index ae6e0c9e..2ea632e1 100644 --- a/tclCommands/TclCommandExportGcode.py +++ b/tclCommands/TclCommandExportGcode.py @@ -78,5 +78,5 @@ class TclCommandExportGcode(TclCommandSignaled): if self.app.collection.has_promises(): self.raise_tcl_error('!!!Promises exists, but should not here!!!') - del args['name'] + args.pop('name', None) return obj.get_gcode(**args) diff --git a/tclCommands/TclCommandFollow.py b/tclCommands/TclCommandFollow.py index 9ef27800..3a59d48a 100644 --- a/tclCommands/TclCommandFollow.py +++ b/tclCommands/TclCommandFollow.py @@ -58,7 +58,7 @@ class TclCommandFollow(TclCommandSignaled): if obj.kind != 'gerber': self.raise_tcl_error('Expected GerberObject, got %s %s.' % (name, type(obj))) - del args['name'] + args.pop('name', None) try: obj.follow_geo(**args) except Exception as e: diff --git a/tclCommands/TclCommandIsolate.py b/tclCommands/TclCommandIsolate.py index ddd6a935..77b09d49 100644 --- a/tclCommands/TclCommandIsolate.py +++ b/tclCommands/TclCommandIsolate.py @@ -93,5 +93,5 @@ class TclCommandIsolate(TclCommandSignaled): if obj.kind != 'gerber': self.raise_tcl_error('Expected GerberObject, got %s %s.' % (name, type(obj))) - del args['name'] + args.pop('name', None) obj.isolate(plot=False, **args) diff --git a/tclCommands/TclCommandMillDrills.py b/tclCommands/TclCommandMillDrills.py index 8a616668..5ad9ead1 100644 --- a/tclCommands/TclCommandMillDrills.py +++ b/tclCommands/TclCommandMillDrills.py @@ -132,10 +132,8 @@ class TclCommandMillDrills(TclCommandSignaled): args['tools'] = 'all' # no longer needed - if 'milled_dias' in args: - del args['milled_dias'] - if 'diatol' in args: - del args['diatol'] + args.pop('milled_dias', None) + args.pop('diatol', None) except Exception as e: self.raise_tcl_error("Bad tools: %s" % str(e)) @@ -147,7 +145,7 @@ class TclCommandMillDrills(TclCommandSignaled): try: # 'name' is not an argument of obj.generate_milling() - del args['name'] + args.pop('name', None) # This runs in the background... Is blocking handled? success, msg = obj.generate_milling_drills(plot=False, **args) diff --git a/tclCommands/TclCommandMillSlots.py b/tclCommands/TclCommandMillSlots.py index e2c8f7a8..2c7da828 100644 --- a/tclCommands/TclCommandMillSlots.py +++ b/tclCommands/TclCommandMillSlots.py @@ -126,22 +126,14 @@ class TclCommandMillSlots(TclCommandSignaled): "TclCommand are not actual tool diameters in the Excellon object.") args['tools'] = req_tools - - # no longer needed - del args['milled_dias'] - del args['diatol'] - # Split and put back. We are passing the whole dictionary later. # args['milled_dias'] = [x.strip() for x in args['tools'].split(",")] else: args['tools'] = 'all' # no longer needed - if 'milled_dias' in args: - del args['milled_dias'] - if 'diatol' in args: - del args['diatol'] - + args.pop('milled_dias', None) + args.pop('diatol', None) except Exception as e: self.raise_tcl_error("Bad tools: %s" % str(e)) @@ -153,7 +145,7 @@ class TclCommandMillSlots(TclCommandSignaled): try: # 'name' is not an argument of obj.generate_milling() - del args['name'] + args.pop('name', None) # This runs in the background... Is blocking handled? success, msg = obj.generate_milling_slots(plot=False, **args) diff --git a/tclCommands/TclCommandNregions.py b/tclCommands/TclCommandNregions.py index 77d442aa..b223fd1e 100644 --- a/tclCommands/TclCommandNregions.py +++ b/tclCommands/TclCommandNregions.py @@ -86,7 +86,7 @@ class TclCommandNregions(TclCommand): else: rounded = bool(eval(self.app.defaults["gerber_noncopperrounded"])) - del args['name'] + args.pop('name', None) try: def geo_init(geo_obj, app_obj):