From 8560a9b57ce0c8844fc642953716554a9d6ca7ac Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Fri, 24 Mar 2023 15:14:48 +0100 Subject: [PATCH 1/2] Stop postprocessing plugin creating unnecessary script folders The idea is to only create scripts in the configuration folder, not in all plugins that register their own resource folder. --- .../PostProcessingPlugin.py | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/plugins/PostProcessingPlugin/PostProcessingPlugin.py b/plugins/PostProcessingPlugin/PostProcessingPlugin.py index 845ad45341..5e37ede4c7 100644 --- a/plugins/PostProcessingPlugin/PostProcessingPlugin.py +++ b/plugins/PostProcessingPlugin/PostProcessingPlugin.py @@ -139,22 +139,26 @@ class PostProcessingPlugin(QObject, Extension): if self._loaded_scripts: # Already loaded. return - # The PostProcessingPlugin path is for built-in scripts. - # The Resources path is where the user should store custom scripts. - # The Preferences path is legacy, where the user may previously have stored scripts. - resource_folders = [PluginRegistry.getInstance().getPluginPath("PostProcessingPlugin"), Resources.getStoragePath(Resources.Preferences)] - resource_folders.extend(Resources.getAllPathsForType(Resources.Resources)) - for root in resource_folders: - if root is None: - continue - path = os.path.join(root, "scripts") + # Make sure a "scripts" folder exists in the main configuration folder and the preferences folder. + # On some platforms the resources and preferences folders resolve to the same folder, + # but on Linux they can be different. + for path in set([os.path.join(Resources.getStoragePath(r), "scripts") for r in [Resources.Resources, Resources.Preferences]]): if not os.path.isdir(path): try: os.makedirs(path) except OSError: Logger.log("w", "Unable to create a folder for scripts: " + path) - continue + # The PostProcessingPlugin path is for built-in scripts. + # The Resources path is where the user should store custom scripts. + # The Preferences path is legacy, where the user may previously have stored scripts. + resource_folders = [PluginRegistry.getInstance().getPluginPath("PostProcessingPlugin"), Resources.getStoragePath(Resources.Preferences)] + resource_folders.extend(Resources.getAllPathsForType(Resources.Resources)) + + for root in resource_folders: + if root is None: + continue + path = os.path.join(root, "scripts") self.loadScripts(path) def loadScripts(self, path: str) -> None: From 1924d8c1b011909e7e7b6019833d0581b934f297 Mon Sep 17 00:00:00 2001 From: Aldo Hoeben Date: Fri, 14 Apr 2023 20:34:59 +0200 Subject: [PATCH 2/2] Continue if there is no scripts folder inside a resource folder Co-authored-by: Casper Lamboo --- plugins/PostProcessingPlugin/PostProcessingPlugin.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/PostProcessingPlugin/PostProcessingPlugin.py b/plugins/PostProcessingPlugin/PostProcessingPlugin.py index 5e37ede4c7..fbb4214021 100644 --- a/plugins/PostProcessingPlugin/PostProcessingPlugin.py +++ b/plugins/PostProcessingPlugin/PostProcessingPlugin.py @@ -159,6 +159,8 @@ class PostProcessingPlugin(QObject, Extension): if root is None: continue path = os.path.join(root, "scripts") + if not os.path.isdir(path): + continue self.loadScripts(path) def loadScripts(self, path: str) -> None: