add a tuxbox plugins plugin to prepare loading of tuxbox plugins when the c++ part...
[enigma2.git] / lib / python / Components / PluginComponent.py
index 172e33e..960043d 100644 (file)
@@ -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()