From: Stefan Pluecken Date: Wed, 11 Jan 2006 14:50:07 +0000 (+0000) Subject: add a tuxbox plugins plugin to prepare loading of tuxbox plugins when the c++ part... X-Git-Tag: 2.6.0~4479 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/47eaccfd3d5c4ca46ff339cb64a077a0f269d671 add a tuxbox plugins plugin to prepare loading of tuxbox plugins when the c++ part supports it --- diff --git a/configure.ac b/configure.ac index fc761e16..07e9cb74 100644 --- a/configure.ac +++ b/configure.ac @@ -60,6 +60,7 @@ lib/python/Components/Makefile lib/python/Screens/Makefile lib/python/Plugins/Makefile lib/python/Plugins/update/Makefile +lib/python/Plugins/tuxboxplugins/Makefile lib/python/Tools/Makefile lib/service/Makefile lib/components/Makefile diff --git a/lib/python/Components/PluginComponent.py b/lib/python/Components/PluginComponent.py index 172e33e3..960043d6 100644 --- a/lib/python/Components/PluginComponent.py +++ b/lib/python/Components/PluginComponent.py @@ -20,32 +20,38 @@ class PluginComponent: for x in dir: path = resolveFilename(SCOPE_PLUGINS, x) + "/" - #try: - if os.path.exists(path): - if fileExists(path + "plugin.py"): - pluginmodule = self.prefix + x + ".plugin" - print "trying to import " + pluginmodule - exec "import " + pluginmodule - plugin = eval(pluginmodule) - picturepaths = plugin.getPicturePaths() - plugins = plugin.getPlugins() - try: - for menuEntry in plugin.getMenuRegistrationList(): - self.menuEntries.append([menuEntry, pluginmodule]) - except: - pass - - for y in range(len(plugins)): - list.append((path + picturepaths[y], plugins[y][0] , x, plugins[y][1], plugins[y][2])) - if runAutostartPlugins: - try: plugin.autostart() - except: pass - if runAutoendPlugins: - try: plugin.autoend() - except: pass - - #except: - # print "Directory", path, "contains a faulty plugin" + try: + if os.path.exists(path): + if fileExists(path + "plugin.py"): + pluginmodule = self.prefix + x + ".plugin" + print "trying to import " + pluginmodule + exec "import " + pluginmodule + plugin = eval(pluginmodule) + plugins = plugin.getPlugins() + try: picturepaths = plugin.getPicturePaths() + except: + picturepaths = [] + for p in plugins: + picturepaths.append("") + try: + for menuEntry in plugin.getMenuRegistrationList(): + self.menuEntries.append([menuEntry, pluginmodule]) + except: + pass + + for y in range(len(plugins)): + if len(plugins[y]) < 4: + list.append((path + picturepaths[y], plugins[y][0] , x, plugins[y][1], plugins[y][2], None)) + else: + list.append((path + picturepaths[y], plugins[y][0] , x, plugins[y][1], plugins[y][2], plugins[y][3])) + if runAutostartPlugins: + try: plugin.autostart() + except: pass + if runAutoendPlugins: + try: plugin.autoend() + except: pass + except: + print "Directory", path, "contains a faulty plugin" self.menuUpdate() return list @@ -58,14 +64,13 @@ class PluginComponent: menuupdater.addMenuItem(menuEntry[0][0], menuEntry[0][2], menuEntry[1], menuEntry[0][3]) def runPlugin(self, plugin, session): - #try: + try: exec("import " + self.prefix + plugin[2] + ".plugin") - print self.prefix + plugin[2] + ".plugin." + plugin[4] if plugin[3] == "screen": - session.open(eval(self.prefix + plugin[2] + ".plugin." + plugin[4])) + session.open(eval(self.prefix + plugin[2] + ".plugin." + plugin[4]), plugin[5]) elif plugin[3] == "function": - eval(self.prefix + plugin[2] + ".plugin." + plugin[4])(session) - #except: - #print "exec of plugin failed!" + eval(self.prefix + plugin[2] + ".plugin." + plugin[4])(session, plugin[5]) + except: + print "exec of plugin failed!" plugins = PluginComponent() diff --git a/lib/python/Plugins/Makefile.am b/lib/python/Plugins/Makefile.am index 21dcb9c8..24ee23da 100644 --- a/lib/python/Plugins/Makefile.am +++ b/lib/python/Plugins/Makefile.am @@ -1,6 +1,6 @@ installdir = $(LIBDIR)/enigma2/python/Plugins -SUBDIRS = update +SUBDIRS = update tuxboxplugins install_PYTHON = \ __init__.py diff --git a/lib/python/Plugins/tuxboxplugins/Makefile.am b/lib/python/Plugins/tuxboxplugins/Makefile.am new file mode 100644 index 00000000..055d9bdd --- /dev/null +++ b/lib/python/Plugins/tuxboxplugins/Makefile.am @@ -0,0 +1,7 @@ +installdir = $(LIBDIR)/enigma2/python/Plugins/tuxboxplugins + +install_PYTHON = \ + __init__.py \ + plugin.py + + diff --git a/lib/python/Plugins/tuxboxplugins/__init__.py b/lib/python/Plugins/tuxboxplugins/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/lib/python/Plugins/tuxboxplugins/plugin.py b/lib/python/Plugins/tuxboxplugins/plugin.py new file mode 100644 index 00000000..1e8d52ee --- /dev/null +++ b/lib/python/Plugins/tuxboxplugins/plugin.py @@ -0,0 +1,14 @@ +from enigma import * +from Screens.Screen import Screen +from Screens.MessageBox import MessageBox +from Components.ActionMap import ActionMap +from Components.Label import Label + +import os + +def getPlugins(): + return [("Tuxbox-Plugin1", "function", "main", 0), + ("Tuxbox-Plugin2", "function", "main", 1)] + +def main(session, args): + print "Running plugin with number", args \ No newline at end of file diff --git a/lib/python/Plugins/update/plugin.py b/lib/python/Plugins/update/plugin.py index 79f67490..8fa21cb3 100644 --- a/lib/python/Plugins/update/plugin.py +++ b/lib/python/Plugins/update/plugin.py @@ -12,7 +12,7 @@ class Example(Screen): """ - def __init__(self, session): + def __init__(self, session, args = None): self.skin = Example.skin Screen.__init__(self, session)