mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-20 12:49:38 +08:00
Don't interrupt loading scripts when one error occurs
Instead of breaking the loading of the rest of the scripts, just don't load this particular one.
This commit is contained in:
parent
b8fce75dac
commit
afeea6e214
@ -118,6 +118,7 @@ class PostProcessingPlugin(QObject, Extension):
|
|||||||
for loader, script_name, ispkg in scripts:
|
for loader, script_name, ispkg in scripts:
|
||||||
# Iterate over all scripts.
|
# Iterate over all scripts.
|
||||||
if script_name not in sys.modules:
|
if script_name not in sys.modules:
|
||||||
|
try:
|
||||||
spec = importlib.util.spec_from_file_location(__name__ + "." + script_name, os.path.join(path, script_name + ".py"))
|
spec = importlib.util.spec_from_file_location(__name__ + "." + script_name, os.path.join(path, script_name + ".py"))
|
||||||
loaded_script = importlib.util.module_from_spec(spec)
|
loaded_script = importlib.util.module_from_spec(spec)
|
||||||
spec.loader.exec_module(loaded_script)
|
spec.loader.exec_module(loaded_script)
|
||||||
@ -139,6 +140,8 @@ class PostProcessingPlugin(QObject, Extension):
|
|||||||
Logger.log("e", "Script %s.py is not a recognised script type. Ensure it inherits Script", script_name)
|
Logger.log("e", "Script %s.py is not a recognised script type. Ensure it inherits Script", script_name)
|
||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
Logger.log("e", "Script %s.py has no implemented settings", script_name)
|
Logger.log("e", "Script %s.py has no implemented settings", script_name)
|
||||||
|
except Exception as e:
|
||||||
|
Logger.logException("e", "Exception occurred while loading post processing plugin: {error_msg}".format(error_msg = str(e)))
|
||||||
self.loadedScriptListChanged.emit()
|
self.loadedScriptListChanged.emit()
|
||||||
|
|
||||||
loadedScriptListChanged = pyqtSignal()
|
loadedScriptListChanged = pyqtSignal()
|
||||||
@ -171,7 +174,6 @@ class PostProcessingPlugin(QObject, Extension):
|
|||||||
|
|
||||||
## Load all scripts in the scripts folders
|
## Load all scripts in the scripts folders
|
||||||
for root in [PluginRegistry.getInstance().getPluginPath("PostProcessingPlugin"), Resources.getStoragePath(Resources.Preferences)]:
|
for root in [PluginRegistry.getInstance().getPluginPath("PostProcessingPlugin"), Resources.getStoragePath(Resources.Preferences)]:
|
||||||
try:
|
|
||||||
path = os.path.join(root, "scripts")
|
path = os.path.join(root, "scripts")
|
||||||
if not os.path.isdir(path):
|
if not os.path.isdir(path):
|
||||||
try:
|
try:
|
||||||
@ -181,8 +183,6 @@ class PostProcessingPlugin(QObject, Extension):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
self.loadAllScripts(path)
|
self.loadAllScripts(path)
|
||||||
except Exception as e:
|
|
||||||
Logger.logException("e", "Exception occurred while loading post processing plugin: {error_msg}".format(error_msg = str(e)))
|
|
||||||
|
|
||||||
# Create the plugin dialog component
|
# Create the plugin dialog component
|
||||||
path = os.path.join(PluginRegistry.getInstance().getPluginPath("PostProcessingPlugin"), "PostProcessingPlugin.qml")
|
path = os.path.join(PluginRegistry.getInstance().getPluginPath("PostProcessingPlugin"), "PostProcessingPlugin.qml")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user