Merge branch 'bug_486_add_service_event_progress_to_servicelist'
[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 from pluginrunner import PluginRunner
6
7 from os import listdir
8
9 TUXBOX_PLUGINS_PATH = "/usr/lib/tuxbox/plugins/"
10
11 def getPlugins():
12         pluginlist = []
13
14         if pathExists(TUXBOX_PLUGINS_PATH):
15                 dir = listdir(TUXBOX_PLUGINS_PATH)
16         
17                 for x in dir:
18                         if x[-3:] == "cfg":
19                                 params = getPluginParams(x)
20                                 pluginlist.append(PluginDescriptor(name=params["name"], description=params["desc"], where = PluginDescriptor.WHERE_PLUGINMENU, icon="tuxbox.png", fnc=boundFunction(main, plugin=x)))
21         
22         return pluginlist
23
24 def getPluginParams(file):
25         params = {}
26         try:
27                 file = open(TUXBOX_PLUGINS_PATH + file, "r")
28                 for x in file.readlines():
29                         split = x.split("=")
30                         params[split[0]] = split[1]
31                 file.close()
32         except IOError:
33                 print "no tuxbox plugins found"
34
35         return params
36
37 def main(session, plugin, **kwargs):
38         print "Running plugin " + plugin[:-4] + ".so with config file", plugin
39         print getPluginParams(plugin)
40         session.open(PluginRunner, plugin[:-4].split(".so")[0])
41         
42 def Plugins(**kwargs):
43         return getPlugins()