From a05ae30a2a119b5635d5caec58ad736f915fd7b2 Mon Sep 17 00:00:00 2001 From: Syres916 <46537884+Syres916@users.noreply.github.com> Date: Sat, 2 May 2020 11:38:19 +0100 Subject: [PATCH] [AddonManager] Add Python 2 Awareness.. ...and improve Git binary version handling. --- src/Mod/AddonManager/addonmanager_workers.py | 146 ++++++++++++++++--- 1 file changed, 127 insertions(+), 19 deletions(-) diff --git a/src/Mod/AddonManager/addonmanager_workers.py b/src/Mod/AddonManager/addonmanager_workers.py index a87d40146a..faf6a356af 100644 --- a/src/Mod/AddonManager/addonmanager_workers.py +++ b/src/Mod/AddonManager/addonmanager_workers.py @@ -51,6 +51,16 @@ OBSOLETE = ["assembly2", "drawing_dimensioning", "cura_engine"] +# These addons will print an additional message informing the user Python2 only +PY2ONLY = ["geodata", + "GDT", + "timber", + "animation"] + +# Minimum Git binary versions for installing/updating Wbs and loading the list of macros +GITWBMIN = "2.14.99" +GITMACMIN = "2.11.99" + NOGIT = False # for debugging purposes, set this to True to always use http downloads @@ -130,6 +140,27 @@ class UpdateWorker(QtCore.QThread): for repo in repos: self.addon_repo.emit(repo) self.info_label.emit(translate("AddonsInstaller", "Workbenches list was updated.")) + git_exe = utils.checkGitBinary() + import platform + try: + out = os.popen(git_exe + ' --version','r') + except: + if platform.system() == 'Windows': + FreeCAD.Console.PrintLog(translate("AddonsInstaller","The Git executable has not been found in the path.")+"\n") + else: + FreeCAD.Console.PrintLog(translate("AddonsInstaller","The Git binary has not been found.")+"\n") + from distutils.version import StrictVersion + if 'out' in locals(): + out_string = out.read() + out.close() + result = re.search('(\d+\.\d+\.\d+)',out_string) + git_version = StrictVersion(result.group(1)) + if platform.system() == 'Windows': + FreeCAD.Console.PrintLog(translate("AddonsInstaller","Found Git executable version ")+str(git_version)+"\n") + else: + FreeCAD.Console.PrintLog(translate("AddonsInstaller","Found Git binary version ")+str(git_version)+"\n") + else: + git_version = StrictVersion("0.0.0") self.progressbar_show.emit(False) self.done.emit() self.stop = True @@ -263,27 +294,58 @@ class FillMacroListWorker(QtCore.QThread): https://github.com/FreeCAD/FreeCAD-macros.git """ + git = None + import os try: import git except ImportError: self.info_label_signal.emit("GitPython not installed! Cannot retrieve macros from Git") - FreeCAD.Console.PrintWarning(translate('AddonsInstaller', 'GitPython not installed! Cannot retrieve macros from git')+"\n") - return - - self.info_label_signal.emit('Downloading list of macros from git...') - try: - git.Repo.clone_from('https://github.com/FreeCAD/FreeCAD-macros.git', self.repo_dir) - except: - FreeCAD.Console.PrintWarning(translate('AddonsInstaller', 'Something went wrong with the Git Macro Retieval, possibly the Git executable is not in the path')+"\n") - for dirpath, _, filenames in os.walk(self.repo_dir): - if '.git' in dirpath: - continue - for filename in filenames: - if filename.lower().endswith('.fcmacro'): - macro = Macro(filename[:-8]) # Remove ".FCMacro". - macro.on_git = True - macro.src_filename = os.path.join(dirpath, filename) - self.macros.append(macro) + FreeCAD.Console.PrintWarning(translate('AddonsInstaller', 'GitPython not installed! Cannot retrieve macros from git, fallback to using the Wiki')+"\n") + if git: + git_exe = utils.checkGitBinary() + import re + try: + out = os.popen(git_exe + ' --version','r') + except: + pass + if 'out' in locals(): + out_string = out.read() + out.close() + result = re.search('(\d+\.\d+\.\d+)',out_string) + from distutils.version import StrictVersion + git_version = StrictVersion(result.group(1)) + git_version_min = StrictVersion(GITMACMIN) + if git_version < git_version_min: + import platform + if platform.system() == 'Windows': + FreeCAD.Console.PrintWarning(translate("AddonsInstaller", "Outdated Git executable detected, consider upgrading or ensure the path to the most recent version is the first one to be found. Cannot retrieve macros from git, fallback to using the Wiki")+"\n") + else: + FreeCAD.Console.PrintWarning(translate("AddonsInstaller", "Outdated Git binary detected, consider upgrading. Cannot retrieve macros from git, fallback to using the Wiki")+"\n") + git = None + else: + self.info_label_signal.emit("Git binary not installed! Cannot retrieve macros from Git") + import platform + if platform.system() == 'Windows': + FreeCAD.Console.PrintWarning(translate('AddonsInstaller', 'Git exectuable not found. Cannot retrieve macros using git, fallback to using the Wiki')+"\n") + else: + FreeCAD.Console.PrintWarning(translate('AddonsInstaller', 'Git binary not found. Cannot retrieve macros using git, fallback to using the Wiki')+"\n") + git = None + if git: + self.info_label_signal.emit('Downloading list of macros from git...') + try: + git.Repo.clone_from('https://github.com/FreeCAD/FreeCAD-macros.git', self.repo_dir) + except: + FreeCAD.Console.PrintWarning(translate('AddonsInstaller', 'Something went wrong with the Git Macro retrieval, fallback to using the Wiki')+"\n") + return + for dirpath, _, filenames in os.walk(self.repo_dir): + if '.git' in dirpath: + continue + for filename in filenames: + if filename.lower().endswith('.fcmacro'): + macro = Macro(filename[:-8]) # Remove ".FCMacro". + macro.on_git = True + macro.src_filename = os.path.join(dirpath, filename) + self.macros.append(macro) def retrieve_macros_from_wiki(self): @@ -442,6 +504,11 @@ class ShowWorker(QtCore.QThread): message = "