forked from geoffwhittington/meshtastic-matrix-relay
-
Notifications
You must be signed in to change notification settings - Fork 1
/
plugin_loader.py
64 lines (51 loc) · 1.92 KB
/
plugin_loader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from log_utils import get_logger
logger = get_logger(name="Plugins")
sorted_active_plugins = []
def load_plugins():
from plugins.health_plugin import Plugin as HealthPlugin
from plugins.map_plugin import Plugin as MapPlugin
from plugins.mesh_relay_plugin import Plugin as MeshRelayPlugin
from plugins.ping_plugin import Plugin as PingPlugin
from plugins.telemetry_plugin import Plugin as TelemetryPlugin
from plugins.weather_plugin import Plugin as WeatherPlugin
from plugins.help_plugin import Plugin as HelpPlugin
from plugins.nodes_plugin import Plugin as NodesPlugin
from plugins.drop_plugin import Plugin as DropPlugin
from plugins.debug_plugin import Plugin as DebugPlugin
from plugins.chutilz_plugin import Plugin as ChutilzPlugin
from plugins.airutilz_plugin import Plugin as AirutilzPlugin
from plugins.voltage_plugin import Plugin as VoltagePlugin
from plugins.battery_plugin import Plugin as BatteryPlugin
from plugins.snr_plugin import Plugin as SNRPlugin
global sorted_active_plugins
if sorted_active_plugins:
return sorted_active_plugins
plugins = [
HealthPlugin(),
MapPlugin(),
MeshRelayPlugin(),
PingPlugin(),
TelemetryPlugin(),
WeatherPlugin(),
HelpPlugin(),
NodesPlugin(),
DropPlugin(),
DebugPlugin(),
ChutilzPlugin(),
AirutilzPlugin(),
VoltagePlugin(),
BatteryPlugin(),
SNRPlugin(),
]
active_plugins = []
for plugin in plugins:
if plugin.config["active"]:
plugin.priority = (
plugin.config["priority"]
if "priority" in plugin.config
else plugin.priority
)
active_plugins.append(plugin)
plugin.start()
sorted_active_plugins = sorted(active_plugins, key=lambda plugin: plugin.priority)
return sorted_active_plugins