forked from gertjanmaas/HueControl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlugins.py
More file actions
18 lines (17 loc) · 735 Bytes
/
Plugins.py
File metadata and controls
18 lines (17 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import os
import sys
import cherrypy
class _Plugins(object):
def __init__(self):
plugin_dir = os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])), 'plugins')
for plugin in os.listdir(plugin_dir):
if plugin[0] != '.' and plugin[0] != '_':
if os.path.isdir(os.path.join(plugin_dir, plugin)):
cherrypy.log("Importing plugin: {0}".format(plugin))
# import the module
m = __import__('{0}.{0}'.format(plugin), fromlist=[plugin])
# get the class
c = getattr(m, plugin)
# create it
self.__dict__[plugin] = c()
Plugins = _Plugins()