Skip to content

Commit 9b74042

Browse files
committed
gui: add support for loading plugins from a users home folder
Allows for plugins to be loaded from ~/dronecan_gui_tool/plugin builds
1 parent 782c6b0 commit 9b74042

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

dronecan_gui_tool/main.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def parse_load_modules(argv):
8383
#
8484
# Importing other stuff once the logging has been configured
8585
#
86+
from pathlib import Path
8687
from serial import SerialException
8788

8889
import dronecan
@@ -113,6 +114,14 @@ def parse_load_modules(argv):
113114
from .panels import PANELS
114115
from .panels import import_panel
115116

117+
# Add the User ~/dronecan_gui_tool/plugins folder to the import path,
118+
# allowing for custom plugin modules to be loaded from there.
119+
plugins_dir = Path.home() / "dronecan_gui_tool" / "plugins"
120+
if plugins_dir.exists():
121+
str_plugin_dir = str(plugins_dir)
122+
if str_plugin_dir not in sys.path:
123+
sys.path.insert(0, str_plugin_dir)
124+
116125
EXT_PLUGINS = []
117126
modules = args.load_module[0] if args.load_module else []
118127
if len(modules) > 0:

0 commit comments

Comments
 (0)