mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -06:00
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.
This commit is contained in:
parent
5330e53ae6
commit
8560a9b57c
1 changed files with 14 additions and 10 deletions
|
@ -139,22 +139,26 @@ class PostProcessingPlugin(QObject, Extension):
|
||||||
if self._loaded_scripts: # Already loaded.
|
if self._loaded_scripts: # Already loaded.
|
||||||
return
|
return
|
||||||
|
|
||||||
# The PostProcessingPlugin path is for built-in scripts.
|
# Make sure a "scripts" folder exists in the main configuration folder and the preferences folder.
|
||||||
# The Resources path is where the user should store custom scripts.
|
# On some platforms the resources and preferences folders resolve to the same folder,
|
||||||
# The Preferences path is legacy, where the user may previously have stored scripts.
|
# but on Linux they can be different.
|
||||||
resource_folders = [PluginRegistry.getInstance().getPluginPath("PostProcessingPlugin"), Resources.getStoragePath(Resources.Preferences)]
|
for path in set([os.path.join(Resources.getStoragePath(r), "scripts") for r in [Resources.Resources, 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")
|
|
||||||
if not os.path.isdir(path):
|
if not os.path.isdir(path):
|
||||||
try:
|
try:
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
except OSError:
|
except OSError:
|
||||||
Logger.log("w", "Unable to create a folder for scripts: " + path)
|
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)
|
self.loadScripts(path)
|
||||||
|
|
||||||
def loadScripts(self, path: str) -> None:
|
def loadScripts(self, path: str) -> None:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue