aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Plugins/Extensions/TuxboxPlugins/plugin.py
blob: 5142d16b3ccc3efa30a934d7af937c159bc394ee (plain)
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
# must be fixed for the new plugin interface
from Tools.BoundFunction import boundFunction
from Tools.Directories import pathExists
from Plugins.Plugin import PluginDescriptor

from os import listdir

TUXBOX_PLUGINS_PATH = "/usr/lib/tuxbox/plugins/"

def getPlugins():
	pluginlist = []

	if pathExists(TUXBOX_PLUGINS_PATH):
		dir = listdir(TUXBOX_PLUGINS_PATH)
	
		for x in dir:
			if x[-3:] == "cfg":
				params = getPluginParams(x)
				pluginlist.append(PluginDescriptor(name=params["name"], description=params["desc"], where = PluginDescriptor.WHERE_PLUGINMENU, icon="tuxbox.png", fnc=boundFunction(main, plugin=x)))
	
	return pluginlist

def getPluginParams(file):
	params = {}
	try:
		file = open(TUXBOX_PLUGINS_PATH + file, "r")
		for x in file.readlines():
			split = x.split("=")
			params[split[0]] = split[1]
		file.close()
	except IOError:
		print "no tuxbox plugins found"

	return params

def main(session, plugin, **kwargs):
	print "Running plugin " + plugin[:-4] + ".so with config file", plugin
	print getPluginParams(plugin)
	
def Plugins(**kwargs):
	return getPlugins()