-
Notifications
You must be signed in to change notification settings - Fork 4
/
plugin.py
54 lines (38 loc) · 981 Bytes
/
plugin.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
from pluginlib import Parent
# Plugin Template
@Parent("Plugin")
class PluginTemplate(object):
''' Plugin Template '''
m_ui = None
def attach_ui(self, ui):
self.m_ui = ui
def on_open(self, ws):
return
def on_close(self, ws, close_status_code, close_msg):
return
def on_error(self, ws, error):
return
def on_recv(self, ws, data, type, continuous):
return
def on_send(self, ws, data, opcode):
return
def on_ping(self, ws, message):
return
def on_pong(self, ws, message):
return
# Plugin Manager
from pluginlib import PluginLoader, PluginImportError
_plugins = None
def plugins():
global _plugins
return [] if _plugins is None else _plugins.Plugin.values()
def initialize(ui):
global _plugins
if _plugins is None:
loader = PluginLoader(modules=["plugins"])
try:
_plugins = loader.plugins
except PluginImportError as e:
print(e)
for e in plugins():
e.attach_ui(e, ui)