From 45b9f2a7aa7fa54bbb2c4902ddfa88b841188b9f Mon Sep 17 00:00:00 2001 From: sliptonic Date: Sat, 25 Jun 2022 10:25:08 -0500 Subject: [PATCH 1/2] Fix import error if camotics not installed. --- src/Mod/Path/PathScripts/PathGuiInit.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathGuiInit.py b/src/Mod/Path/PathScripts/PathGuiInit.py index 02846c5d70..185fa680f3 100644 --- a/src/Mod/Path/PathScripts/PathGuiInit.py +++ b/src/Mod/Path/PathScripts/PathGuiInit.py @@ -21,6 +21,7 @@ # *************************************************************************** import PathScripts.PathLog as PathLog +import subprocess LOGLEVEL = False @@ -49,7 +50,6 @@ def Startup(): from PathScripts import PathDressupPathBoundaryGui from PathScripts import PathDressupRampEntry from PathScripts import PathDressupTagGui - from PathScripts import PathDressupLeadInOut from PathScripts import PathDressupZCorrect from PathScripts import PathDrillingGui from PathScripts import PathEngraveGui @@ -68,7 +68,6 @@ def Startup(): from PathScripts import PathSetupSheetGui from PathScripts import PathSimpleCopy from PathScripts import PathSimulatorGui - from PathScripts import PathCamoticsGui from PathScripts import PathSlotGui from PathScripts import PathStop from PathScripts import PathThreadMillingGui @@ -79,6 +78,17 @@ def Startup(): from PathScripts import PathUtilsGui from PathScripts import PathVcarveGui + # If camotics is installed and current enough, import the GUI + try: + r = subprocess.run( + ["camotics", "--version"], capture_output=True, text=True + ).stderr.strip() + major, minor, patch = r.split(".") + if int(major) >= 1 and int(minor) >= 2 and int(patch) >= 2: + from PathScripts import PathCamoticsGui + except FileNotFoundError: + pass + Processed = True else: PathLog.debug("Skipping PathGui initialisation") From a84220cd21eba023f2bdbdd158e4e3a3434cbef4 Mon Sep 17 00:00:00 2001 From: sliptonic Date: Sun, 26 Jun 2022 14:09:28 -0500 Subject: [PATCH 2/2] Also check that the module imports correctly --- src/Mod/Path/PathScripts/PathGuiInit.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Mod/Path/PathScripts/PathGuiInit.py b/src/Mod/Path/PathScripts/PathGuiInit.py index 185fa680f3..5786c507bb 100644 --- a/src/Mod/Path/PathScripts/PathGuiInit.py +++ b/src/Mod/Path/PathScripts/PathGuiInit.py @@ -80,13 +80,14 @@ def Startup(): # If camotics is installed and current enough, import the GUI try: + import camotics r = subprocess.run( ["camotics", "--version"], capture_output=True, text=True ).stderr.strip() major, minor, patch = r.split(".") if int(major) >= 1 and int(minor) >= 2 and int(patch) >= 2: from PathScripts import PathCamoticsGui - except FileNotFoundError: + except (FileNotFoundError, ModuleNotFoundError): pass Processed = True