kopia lustrzana https://github.com/mate-dev/meshtastic-matrix-relay
try to support .exe custom plugin
rodzic
148c74cabe
commit
ec26b9cb6e
|
@ -1,8 +1,12 @@
|
|||
import os
|
||||
import sys
|
||||
import importlib
|
||||
from pathlib import Path
|
||||
from log_utils import get_logger
|
||||
|
||||
# Get the path to the PyInstaller script
|
||||
launch_dir = os.path.abspath(os.path.dirname(sys.argv[0]))
|
||||
|
||||
logger = get_logger(name="Plugins")
|
||||
|
||||
plugins = []
|
||||
|
@ -14,7 +18,7 @@ def load_plugins():
|
|||
return plugins
|
||||
|
||||
plugins = []
|
||||
plugin_dirs = [Path("plugins"), Path("custom_plugins")]
|
||||
plugin_dirs = [Path("plugins"), Path(launch_dir, "custom_plugins")]
|
||||
|
||||
for plugin_folder in plugin_dirs:
|
||||
sys.path.insert(0, str(plugin_folder.resolve()))
|
||||
|
@ -26,8 +30,13 @@ def load_plugins():
|
|||
plugin_module = importlib.import_module(plugin_name)
|
||||
if hasattr(plugin_module, "Plugin"):
|
||||
plugin = plugin_module.Plugin()
|
||||
logger.debug(
|
||||
f"Found plugin {os.path.basename(plugin_folder)}/{plugin_name}"
|
||||
)
|
||||
if plugin.config["active"]:
|
||||
logger.debug(f"Loaded plugin {plugin_folder/plugin_name}")
|
||||
logger.info(
|
||||
f"Loaded plugin {os.path.basename(plugin_folder)}/{plugin_name}"
|
||||
)
|
||||
plugins.append(plugin)
|
||||
|
||||
return plugins
|
||||
|
|
Ładowanie…
Reference in New Issue