Merge pull request #1203 from ingoratsdorf/pluginloader-fix
Some checks failed
Code checks / check-url-paths (push) Has been cancelled
docker / docker_dev (push) Has been cancelled
Deploy MkDocs / deploy (push) Has been cancelled

Make plugin loader more robust
This commit is contained in:
Jokob @NetAlertX
2025-09-27 16:26:30 +10:00
committed by GitHub

View File

@@ -202,6 +202,7 @@ def get_plugins_configs(loadAll):
# Construct the path to the config.json file within the plugin folder # Construct the path to the config.json file within the plugin folder
config_path = os.path.join(pluginsPath, d, "config.json") config_path = os.path.join(pluginsPath, d, "config.json")
try:
plugJson = json.loads(get_file_content(config_path)) plugJson = json.loads(get_file_content(config_path))
# Only load plugin if needed # Only load plugin if needed
@@ -215,6 +216,12 @@ def get_plugins_configs(loadAll):
# Load the contents of the config.json file as a JSON object and append it to pluginsList # Load the contents of the config.json file as a JSON object and append it to pluginsList
pluginsList.append(plugJson) pluginsList.append(plugJson)
except (FileNotFoundError, json.JSONDecodeError) as e:
# Handle the case when the file is not found or JSON decoding fails
mylog('none', [f'[{module_name}] ⚠ ERROR - JSONDecodeError or FileNotFoundError for file {config_path}'])
except Exception as e:
mylog('none', [f'[{module_name}] ⚠ ERROR - Exception for file {config_path}: {str(e)}'])
# Sort pluginsList based on "execution_order" # Sort pluginsList based on "execution_order"
pluginsListSorted = sorted(pluginsList, key=get_layer) pluginsListSorted = sorted(pluginsList, key=get_layer)