plugin api change: Plugins() and main functions must receive (and possibly ignore...
authorFelix Domke <tmbinc@elitedvb.net>
Sun, 5 Mar 2006 21:43:54 +0000 (21:43 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Sun, 5 Mar 2006 21:43:54 +0000 (21:43 +0000)
12 files changed:
doc/PLUGINS
lib/python/Plugins/DemoPlugins/TestPlugin/plugin.py
lib/python/Plugins/Extensions/CutListEditor/plugin.py
lib/python/Plugins/Extensions/FileManager/plugin.py
lib/python/Plugins/Extensions/TuxboxPlugins/plugin.py
lib/python/Plugins/Extensions/WebInterface/plugin.py
lib/python/Plugins/Extensions/ZappingAlternatives/plugin.py
lib/python/Plugins/Plugin.py
lib/python/Plugins/SystemPlugins/FrontprocessorUpgrade/plugin.py
lib/python/Plugins/SystemPlugins/OldSoftwareUpdate/plugin.py
lib/python/Plugins/SystemPlugins/PositionerSetup/plugin.py
lib/python/Plugins/SystemPlugins/SoftwareUpdate/plugin.py

index 9655877..c383997 100644 (file)
@@ -5,19 +5,20 @@ Enigma2 plugins are always written in python. If you really have to call
 C/C++ functions from your code, you can supply a python module with it,
 implementing your functions.
 
 C/C++ functions from your code, you can supply a python module with it,
 implementing your functions.
 
-Let's write a plugin. We call it "ourSmallTest", and it should be a test
-plugin.
+Let's write a plugin. We call it "OurSmallTest", and it should be a test
+plugin. Thus we choose "DemoPlugins" as a category. The category is just to
+organize plugins in the filesystem.
 
 The simplest plugin looks like the following:
 
 
 The simplest plugin looks like the following:
 
-Plugins/ourSmallTest/plugin.py:
+Plugins/DemoPlugins/OurSmallTest/plugin.py:
 
 "from Plugins.Plugin import PluginDescriptor
 
 
 "from Plugins.Plugin import PluginDescriptor
 
-def main(session):
+def main(session, **kwargs):
        print "Hello world!"
 
        print "Hello world!"
 
-def Plugins():
+def Plugins(**kwargs):
        return PluginDescriptor(
                name="Our Small Test", 
                description="plugin to test some capabilities", 
        return PluginDescriptor(
                name="Our Small Test", 
                description="plugin to test some capabilities", 
@@ -68,6 +69,12 @@ def main(session):
 
 with MyScreen being a GUI screen.
 
 
 with MyScreen being a GUI screen.
 
+About the **kwargs:
+This somewhat special syntax (in fact the name 'kwargs' is arbitrary, but
+stands for "keyword arguments") collects all addition keyword arguments
+(i.e. named parameters). For example. the Plugins()-call gets a "path"
+parameter, and probably more in the future. You must ignore all additional
+keywords which you don't need!
 
 autostarting plugins
 ====================
 
 autostarting plugins
 ====================
@@ -78,8 +85,17 @@ end on shutdown.
 you just have to use "WHERE_AUTOSTART". your entry point must (fnc) look 
 like:
 
 you just have to use "WHERE_AUTOSTART". your entry point must (fnc) look 
 like:
 
-def autostartEntry(raeson):
+def autostartEntry(raeson, **kwargs):
        if reason == 0: # startup
                print "startup"
        elif reason == 1:
                print "shutdown"
        if reason == 0: # startup
                print "startup"
        elif reason == 1:
                print "shutdown"
+
+Categories
+==========
+
+Currently defined categories are:
+
+* DemoPlugins: Plugins fore pure demonstration purposes
+* Extensions: User interface extensions
+* SystemPlugins: Hardware specific plugins
index 1d21ea3..e6d83bf 100644 (file)
@@ -68,13 +68,11 @@ class Test(Screen):
                print "pressed", number
                self["text"].number(number)
 
                print "pressed", number
                self["text"].number(number)
 
-def main(session):
+def main(session, **kwargs):
        session.openWithCallback(test, ChoiceBox, title="Delete everything on this Dreambox?", list=[(_("yes"), "yes"), (_("no"), "no"), (_("perhaps"), "perhaps"), (_("ask me tomorrow"), "ask me tomorrow"), (_("leave me alone with this!"), "yes")])
        
 def test(returnValue):
        print "You entered", returnValue
 
        session.openWithCallback(test, ChoiceBox, title="Delete everything on this Dreambox?", list=[(_("yes"), "yes"), (_("no"), "no"), (_("perhaps"), "perhaps"), (_("ask me tomorrow"), "ask me tomorrow"), (_("leave me alone with this!"), "yes")])
        
 def test(returnValue):
        print "You entered", returnValue
 
-def Plugins():
-       return PluginDescriptor(name="Test", description="plugin to test some capabilities", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main)
-
-       
\ No newline at end of file
+def Plugins(**kwargs):
+       return PluginDescriptor(name="Test", description="plugin to test some capabilities", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main)
index 25a5e74..16616cd 100644 (file)
@@ -338,8 +338,8 @@ Then seek to the end, press OK, select 'end cut'. That's it.
                        self.cut_list.remove(self.context_nearest_mark)
                        self.uploadCuesheet()
 
                        self.cut_list.remove(self.context_nearest_mark)
                        self.uploadCuesheet()
 
-def main(session, service):
+def main(session, service, **kwargs):
        session.open(CutListEditor, service)
 
        session.open(CutListEditor, service)
 
-def Plugins():
+def Plugins(**kwargs):
        return PluginDescriptor(name="Cutlist Editor", description=_("Cutlist editor..."), where = PluginDescriptor.WHERE_MOVIELIST, fnc=main)
        return PluginDescriptor(name="Cutlist Editor", description=_("Cutlist editor..."), where = PluginDescriptor.WHERE_MOVIELIST, fnc=main)
index 05a19fc..a17e631 100644 (file)
@@ -62,8 +62,8 @@ class FileManager(Screen):
                print "pressed", number
                self["text"].number(number)
 
                print "pressed", number
                self["text"].number(number)
 
-def main(session):
+def main(session, **kwargs):
        session.open(FileManager)
 
        session.open(FileManager)
 
-def Plugins():
+def Plugins(**kwargs):
        return PluginDescriptor(name="File-Manager", description="Let's you view/edit files in your Dreambox", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main)
        return PluginDescriptor(name="File-Manager", description="Let's you view/edit files in your Dreambox", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main)
index 7ab02da..8d4e158 100644 (file)
@@ -38,9 +38,9 @@ def getPluginParams(file):
 
        return params
 
 
        return params
 
-def main(session, plugin):
+def main(session, plugin, **kwargs):
        print "Running plugin " + plugin[:-4] + ".so with config file", plugin
        print getPluginParams(plugin)
        
        print "Running plugin " + plugin[:-4] + ".so with config file", plugin
        print getPluginParams(plugin)
        
-def Plugins():
-       return getPlugins()
\ No newline at end of file
+def Plugins(**kwargs):
+       return getPlugins()
index f0be4e4..0f7e2bb 100644 (file)
@@ -8,12 +8,12 @@ def startWebserver():
        
        reactor.listenTCP(80, http.HTTPFactory(site))
 
        
        reactor.listenTCP(80, http.HTTPFactory(site))
 
-def autostart(reason):
+def autostart(reason, **kwargs):
        if reason == 0:
                try:
                        startWebserver()
                except ImportError:
                        print "twisted not available, not starting web services"
 
        if reason == 0:
                try:
                        startWebserver()
                except ImportError:
                        print "twisted not available, not starting web services"
 
-def Plugins():
+def Plugins(**kwargs):
        return PluginDescriptor(where = PluginDescriptor.WHERE_AUTOSTART, fnc = autostart)
        return PluginDescriptor(where = PluginDescriptor.WHERE_AUTOSTART, fnc = autostart)
index dace8dd..118f0cb 100644 (file)
@@ -294,9 +294,9 @@ def autostart(reason):
                NavigationInstance.instance.playService = type(NavigationInstance.instance.playService)(playService, NavigationInstance, Navigation)
                
 
                NavigationInstance.instance.playService = type(NavigationInstance.instance.playService)(playService, NavigationInstance, Navigation)
                
 
-def AlternativeZappingSetup(session):
+def AlternativeZappingSetup(session, **kwargs):
        session.open(AlternativeZapping)
 
        session.open(AlternativeZapping)
 
-def Plugins():
+def Plugins(**kwargs):
        return [PluginDescriptor(where = PluginDescriptor.WHERE_AUTOSTART, fnc = autostart),
                        PluginDescriptor(name="Alternative services setup" , description="Defines alternatives for services.", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=AlternativeZappingSetup)]
        return [PluginDescriptor(where = PluginDescriptor.WHERE_AUTOSTART, fnc = autostart),
                        PluginDescriptor(name="Alternative services setup" , description="Defines alternatives for services.", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=AlternativeZappingSetup)]
index 3db7039..2c8d929 100644 (file)
@@ -11,6 +11,8 @@ class PluginDescriptor:
        #   servicereference
        #   reason
        
        #   servicereference
        #   reason
        
+       # you have to ignore unknown kwargs!
+       
        # argument: session
        WHERE_BLUEMENU = 0
        WHERE_MAINMENU = 1
        # argument: session
        WHERE_BLUEMENU = 0
        WHERE_MAINMENU = 1
@@ -44,7 +46,7 @@ class PluginDescriptor:
 
        def updateIcon(self, path):
                if type(self.iconstr) is str:
 
        def updateIcon(self, path):
                if type(self.iconstr) is str:
-                       self.icon = loadPNG(path + self.iconstr)
+                       self.icon = loadPNG(path + "/" + self.iconstr)
                else:
                        self.icon = None
 
                else:
                        self.icon = None
 
index fea3842..94c81c0 100644 (file)
@@ -44,7 +44,7 @@ class FPUpgrade(Screen):
        def ok(self):
                self.close(4)
 
        def ok(self):
                self.close(4)
 
-def Plugins():
+def Plugins(**kwargs):
        from Tools.DreamboxHardware import getFPVersion
        version = getFPVersion()
        newversion = getUpgradeVersion() or 0
        from Tools.DreamboxHardware import getFPVersion
        version = getFPVersion()
        newversion = getUpgradeVersion() or 0
index 0dc53a6..72279c1 100644 (file)
@@ -166,12 +166,12 @@ class Ipkg(Screen):
                else:
                        self.close()
 
                else:
                        self.close()
 
-def UpgradeMain(session):
+def UpgradeMain(session, **kwargs):
        session.open(Upgrade)
 
        session.open(Upgrade)
 
-def IpkgMain(session):
+def IpkgMain(session, **kwargs):
        session.open(Ipkg)
 
        session.open(Ipkg)
 
-def Plugins():
+def Plugins(**kwargs):
        return [PluginDescriptor(name="Old Softwareupdate", description="Updates your receiver's software", icon="update.png", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=UpgradeMain),
                        PluginDescriptor(name="IPKG", description="IPKG frontend", icon="update.png", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=IpkgMain)]
        return [PluginDescriptor(name="Old Softwareupdate", description="Updates your receiver's software", icon="update.png", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=UpgradeMain),
                        PluginDescriptor(name="IPKG", description="IPKG frontend", icon="update.png", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=IpkgMain)]
index cd39fec..579f6c9 100644 (file)
@@ -129,9 +129,8 @@ class PositionerSetup(Screen):
                else:
                        self.status.setText("not moving")
                
                else:
                        self.status.setText("not moving")
                
-def PositionerMain(session):
+def PositionerMain(session, **kwargs):
        session.open(PositionerSetup)
 
        session.open(PositionerSetup)
 
-def Plugins():
+def Plugins(**kwargs):
        return PluginDescriptor(name="Positioner setup", description="Setup your positioner", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=PositionerMain)
        return PluginDescriptor(name="Positioner setup", description="Setup your positioner", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=PositionerMain)
-
index 00f8e18..af4d898 100644 (file)
@@ -219,8 +219,8 @@ class Ipkg(Screen):
                else:
                        self.close()
 
                else:
                        self.close()
 
-def UpgradeMain(session):
+def UpgradeMain(session, **kwargs):
        session.open(UpdatePluginMenu)
 
        session.open(UpdatePluginMenu)
 
-def Plugins():
+def Plugins(**kwargs):
        return PluginDescriptor(name="Softwareupdate", description="Updates your receiver's software", icon="update.png", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=UpgradeMain)
        return PluginDescriptor(name="Softwareupdate", description="Updates your receiver's software", icon="update.png", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=UpgradeMain)