-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathpluginmanager.py
49 lines (37 loc) · 1.42 KB
/
pluginmanager.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
###########################################################################
# Sint Wind PI
# Copyright 2012 by Tonino Tarsi <[email protected]>
#
# USB comunication based pywws by 'Jim Easterbrook' <[email protected]>
# Please refer to the LICENSE file for conditions
# Visit http://www.vololiberomontecucco.it
#
##########################################################################
""" plugin manager."""
import os
import sys
import importlib
import config
from TTLib import *
class PluginLoader():
def __init__(self, path,cfg):
self.path = path
self.cfg = cfg
def loadAll(self):
log("loading plugins")
for (dirpath, dirs, files) in os.walk(self.path):
if not dirpath in sys.path:
sys.path.insert(0, dirpath)
for file in files:
(name, ext) = os.path.splitext(file)
if ext == os.extsep + "py":
if ( name != "example" and name !="sync_plugin" and name != "__init__"):
mod = importlib.import_module(name)
swpi_plugin_Thread = mod.swpi_plugin(self.cfg)
swpi_plugin_Thread.start()
if __name__ == '__main__':
print "starting"
configfile = 'swpi.cfg'
cfg = config.config(configfile)
pl = PluginLoader("./plugins",cfg)
pl.loadAll()