From 63ceb8d9f5845a5de55ba293b9ae9bcf45bd0718 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Mon, 25 Apr 2022 12:41:55 -0500 Subject: [PATCH] Addon Manager: Fetch allowed py packages from Github repo --- src/Mod/AddonManager/AddonManager.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Mod/AddonManager/AddonManager.py b/src/Mod/AddonManager/AddonManager.py index 9b6a947f22..8147c6c0dc 100644 --- a/src/Mod/AddonManager/AddonManager.py +++ b/src/Mod/AddonManager/AddonManager.py @@ -999,12 +999,29 @@ class CommandAddonManager: if option not in self.python_required ] + def update_allowed_packages_list(self) -> None: + FreeCAD.Console.PrintLog("Attempting to fetch remote copy of ALLOWED_PYTHON_PACKAGES.txt...\n") + p = NetworkManager.AM_NETWORK_MANAGER.blocking_get( + "https://raw.githubusercontent.com/FreeCAD/FreeCAD-addons/master/ALLOWED_PYTHON_PACKAGES.txt" + ) + if p: + FreeCAD.Console.PrintLog("Remote ALLOWED_PYTHON_PACKAGES.txt file located, overriding locally-installed copy\n") + p = p.data().decode("utf8") + lines = p.split("\n") + self.allowed_packages.clear() # Unset the locally-defined list + for line in lines: + if line and len(line) > 0 and line[0] != "#": + self.allowed_packages.add(line.strip()) + else: + FreeCAD.Console.PrintLog("Could not fetch remote ALLOWED_PYTHON_PACKAGES.txt, using local copy\n") + def handle_disallowed_python(self, python_required: List[str]) -> bool: """Determine if we are missing any required Python packages that are not in the allowed packages list. If so, display a message to the user, and return True. Otherwise return False.""" bad_packages = [] + self.update_allowed_packages_list() for dep in python_required: if dep not in self.allowed_packages: bad_packages.append(dep)