From ade72dc869b04f99d326d3f8b08e6accebaf64bf Mon Sep 17 00:00:00 2001 From: sliptonic Date: Tue, 28 Jun 2022 15:10:49 -0500 Subject: [PATCH] Another import bug. This time if --version doesn't return a patch number. --- src/Mod/Path/InitGui.py | 9 +++++---- src/Mod/Path/PathScripts/PathGuiInit.py | 8 ++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Mod/Path/InitGui.py b/src/Mod/Path/InitGui.py index 85a6be3433..9fa9b32c52 100644 --- a/src/Mod/Path/InitGui.py +++ b/src/Mod/Path/InitGui.py @@ -89,6 +89,7 @@ class PathWorkbench(Workbench): import PathCommands import subprocess + from packaging.version import Version, parse PathGuiInit.Startup() @@ -162,11 +163,11 @@ class PathWorkbench(Workbench): 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: - # subprocess.call(["camsim", "-v"]) + v = parse(r) + + if v >= Version("1.2.2"): toolcmdlist.append("Path_Camotics") - except FileNotFoundError: + except (FileNotFoundError, ModuleNotFoundError): pass try: diff --git a/src/Mod/Path/PathScripts/PathGuiInit.py b/src/Mod/Path/PathScripts/PathGuiInit.py index 5786c507bb..fca0052a5a 100644 --- a/src/Mod/Path/PathScripts/PathGuiInit.py +++ b/src/Mod/Path/PathScripts/PathGuiInit.py @@ -78,14 +78,18 @@ def Startup(): from PathScripts import PathUtilsGui from PathScripts import PathVcarveGui + from packaging.version import Version, parse + # 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: + + v = parse(r) + if v >= Version("1.2.2"): from PathScripts import PathCamoticsGui except (FileNotFoundError, ModuleNotFoundError): pass