some python import cleanups
[enigma2.git] / lib / python / Plugins / Extensions / TuxboxPlugins / plugin.py
1 # must be fixed for the new plugin interface
2 from Tools.BoundFunction import boundFunction
3 from Tools.Directories import pathExists
4 from Plugins.Plugin import PluginDescriptor
5
6 from os import listdir
7
8 TUXBOX_PLUGINS_PATH = "/usr/lib/tuxbox/plugins/"
9
10 def getPlugins():
11         pluginlist = []
12
13         if pathExists(TUXBOX_PLUGINS_PATH):
14                 dir = listdir(TUXBOX_PLUGINS_PATH)
15         
16                 for x in dir:
17                         if x[-3:] == "cfg":
18                                 params = getPluginParams(x)
19                                 pluginlist.append(PluginDescriptor(name=params["name"], description=params["desc"], where = PluginDescriptor.WHERE_PLUGINMENU, icon="tuxbox.png", fnc=boundFunction(main, plugin=x)))
20         
21         return pluginlist
22
23 def getPluginParams(file):
24         params = {}
25         try:
26                 file = open(TUXBOX_PLUGINS_PATH + file, "r")
27                 for x in file.readlines():
28                         split = x.split("=")
29                         params[split[0]] = split[1]
30                 file.close()
31         except IOError:
32                 print "no tuxbox plugins found"
33
34         return params
35
36 def main(session, plugin, **kwargs):
37         print "Running plugin " + plugin[:-4] + ".so with config file", plugin
38         print getPluginParams(plugin)
39         
40 def Plugins(**kwargs):
41         return getPlugins()