3 from Tools.Directories import *
4 from Screens.Menu import menuupdater
9 self.setPluginPrefix("Plugins.")
12 def setPluginPrefix(self, prefix):
15 def getPluginList(self, runAutostartPlugins=False, runAutoendPlugins=False):
17 dir = os.listdir(resolveFilename(SCOPE_PLUGINS))
22 path = resolveFilename(SCOPE_PLUGINS, x) + "/"
24 if os.path.exists(path):
25 if fileExists(path + "plugin.py"):
26 pluginmodule = self.prefix + x + ".plugin"
27 print "trying to import " + pluginmodule
28 exec "import " + pluginmodule
29 plugin = eval(pluginmodule)
30 plugins = plugin.getPlugins()
31 try: picturepaths = plugin.getPicturePaths()
35 picturepaths.append("")
37 for menuEntry in plugin.getMenuRegistrationList():
38 self.menuEntries.append([menuEntry, pluginmodule])
42 for y in range(len(plugins)):
43 if len(plugins[y]) < 5:
44 list.append((path + picturepaths[y], plugins[y][0] , x, plugins[y][2], plugins[y][3], None, plugins[y][1]))
46 list.append((path + picturepaths[y], plugins[y][0] , x, plugins[y][2], plugins[y][3], plugins[y][4], plugins[y][1]))
47 if runAutostartPlugins:
48 try: plugin.autostart()
54 print "Directory", path, "contains a faulty plugin"
59 for menuEntry in self.menuEntries:
60 menuupdater.delMenuItem(menuEntry[0][0], menuEntry[0][1], menuEntry[0][2], menuEntry[1], menuEntry[0][3])
63 for menuEntry in self.menuEntries:
64 menuupdater.addMenuItem(menuEntry[0][0], menuEntry[0][1], menuEntry[0][2], menuEntry[1], menuEntry[0][3])
66 def runPlugin(self, plugin, session):
68 exec("import " + self.prefix + plugin[2] + ".plugin")
69 if plugin[3] == "screen":
70 session.open(eval(self.prefix + plugin[2] + ".plugin." + plugin[4]), plugin[5])
71 elif plugin[3] == "function":
72 eval(self.prefix + plugin[2] + ".plugin." + plugin[4])(session, plugin[5])
74 print "exec of plugin failed!"
76 plugins = PluginComponent()