use external program (i.e. pluginx) to start tuxbox plugins
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Wed, 8 Oct 2008 14:52:52 +0000 (14:52 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Wed, 8 Oct 2008 14:52:52 +0000 (14:52 +0000)
lib/python/Plugins/Extensions/TuxboxPlugins/plugin.py
lib/python/Plugins/Extensions/TuxboxPlugins/pluginrunner.py [new file with mode: 0644]

index 5142d16..05085ea 100644 (file)
@@ -2,6 +2,7 @@
 from Tools.BoundFunction import boundFunction
 from Tools.Directories import pathExists
 from Plugins.Plugin import PluginDescriptor
+from pluginrunner import PluginRunner
 
 from os import listdir
 
@@ -36,6 +37,7 @@ def getPluginParams(file):
 def main(session, plugin, **kwargs):
        print "Running plugin " + plugin[:-4] + ".so with config file", plugin
        print getPluginParams(plugin)
+       session.open(PluginRunner, plugin[:-4].split(".so")[0])
        
 def Plugins(**kwargs):
        return getPlugins()
diff --git a/lib/python/Plugins/Extensions/TuxboxPlugins/pluginrunner.py b/lib/python/Plugins/Extensions/TuxboxPlugins/pluginrunner.py
new file mode 100644 (file)
index 0000000..71f935c
--- /dev/null
@@ -0,0 +1,37 @@
+from enigma import eDBoxLCD, eRCInput, fbClass, eConsoleAppContainer
+from Screens.Screen import Screen
+from Screens.MessageBox import MessageBox
+
+class PluginRunner(Screen):
+       skin = """
+               <screen position="1,1" size="1,1" title="Plugin" >
+        </screen>"""
+       def __init__(self, session, pluginname, args = None):
+               self.skin = PluginRunner.skin
+               Screen.__init__(self, session)
+               self.container = eConsoleAppContainer()
+               self.container.appClosed.get().append(self.finishedExecution)
+               self.runPlugin(pluginname)
+               
+       def runPlugin(self, pluginname):
+               eDBoxLCD.getInstance().lock()
+               eRCInput.getInstance().lock()
+               fbClass.getInstance().lock()
+               print "executing:", ("pluginlauncher -x %s" % pluginname)
+               if self.container.execute("pluginlauncher -x %s" % pluginname):
+                       self.finishedExecution(None)
+                       
+       def finishedExecution(self, retval = 1):
+               print "PluginRunner retval:", retval
+               fbClass.getInstance().unlock()
+               eRCInput.getInstance().unlock()
+               eDBoxLCD.getInstance().unlock()
+               
+               if retval is None or retval != 1:
+                       self.session.openWithCallback(
+                               self.finishedExecution,
+                               MessageBox,
+                               _("Error executing plugin") % (param)
+                       )
+               else:
+                       self.close()