moonraker: handle "prefix" section during inital load
Only load the plugin for each prefix section once. Plugins themselves will be responsible for parsing the configuration from each prefix section. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
d18fc889d5
commit
0a7b580799
|
@ -100,7 +100,7 @@ class Server:
|
|||
self.load_plugin(config, plugin)
|
||||
|
||||
# check for optional plugins
|
||||
opt_sections = set(config.sections()) - \
|
||||
opt_sections = set([s.split()[0] for s in config.sections()]) - \
|
||||
set(['server', 'authorization', 'cmd_args'])
|
||||
for section in opt_sections:
|
||||
self.load_plugin(config, section, None)
|
||||
|
@ -119,9 +119,12 @@ class Server:
|
|||
return default
|
||||
module = importlib.import_module("plugins." + plugin_name)
|
||||
try:
|
||||
if plugin_name not in CORE_PLUGINS:
|
||||
func_name = "load_plugin"
|
||||
if hasattr(module, "load_plugin_multi"):
|
||||
func_name = "load_plugin_multi"
|
||||
if plugin_name not in CORE_PLUGINS and func_name == "load_plugin":
|
||||
config = config[plugin_name]
|
||||
load_func = getattr(module, "load_plugin")
|
||||
load_func = getattr(module, func_name)
|
||||
plugin = load_func(config)
|
||||
except Exception:
|
||||
msg = f"Unable to load plugin ({plugin_name})"
|
||||
|
|
Loading…
Reference in New Issue