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