allow binary only python plugins
[enigma2.git] / mytest.py
index 1823d8c22fc2c132b00d41e5a1f125a7666ea3eb..329bba269f53af783606b3b8f9b31f7ea7d39d9f 100644 (file)
--- a/mytest.py
+++ b/mytest.py
@@ -1,3 +1,4 @@
+from Tools import RedirectOutput
 from enigma import *
 from tools import *
 
@@ -16,29 +17,32 @@ from Navigation import Navigation
 from skin import readSkin, applyAllAttributes
 
 from Components.config import configfile
-from Tools.Directories import InitFallbackFiles
+from Tools.Directories import InitFallbackFiles, resolveFilename, SCOPE_PLUGINS
 InitFallbackFiles()
 eDVBDB.getInstance().reloadBouquets()
 
 try:
-       from twisted.internet import e2reactor
+       import e2reactor
        e2reactor.install()
        
        from twisted.internet import reactor
        
        def runReactor():
                reactor.run()
-except:
+except ImportError:
+       print "twisted not available"
        def runReactor():
                runMainloop()
 
 # initialize autorun plugins and plugin menu entries
 from Components.PluginComponent import plugins
-plugins.getPluginList(runAutostartPlugins=True)
+plugins.readPluginList(resolveFilename(SCOPE_PLUGINS))
+
 from Screens.Wizard import wizardManager
 from Screens.StartWizard import *
 from Screens.TutorialWizard import *
 from Tools.BoundFunction import boundFunction
+from Plugins.Plugin import PluginDescriptor
 
 had = dict()
 
@@ -110,28 +114,28 @@ class Session:
 
                # when execBegin opened a new dialog, don't bother showing the old one.
                if c == self.currentDialog:
-                       c.instance.show()
+                       c.show()
                
        def execEnd(self):
                self.currentDialog.execEnd()
-               self.currentDialog.instance.hide()
+               self.currentDialog.hide()
        
-       def create(self, screen, arguments):
+       def create(self, screen, arguments, **kwargs):
                # creates an instance of 'screen' (which is a class)
                try:
-                       return screen(self, *arguments)
+                       return screen(self, *arguments, **kwargs)
                except:
-                       errstr = "Screen %s(%s): %s" % (str(screen), str(arguments), sys.exc_info()[0])
+                       errstr = "Screen %s(%s, %s): %s" % (str(screen), str(arguments), str(kwargs), sys.exc_info()[0])
                        print errstr
                        traceback.print_exc(file=sys.stdout)
                        quitMainloop(5)
                        
        
-       def instantiateDialog(self, screen, *arguments):
+       def instantiateDialog(self, screen, *arguments, **kwargs):
                # create dialog
                
                try:
-                       dlg = self.create(screen, arguments)
+                       dlg = self.create(screen, arguments, **kwargs)
                except:
                        print 'EXCEPTION IN DIALOG INIT CODE, ABORTING:'
                        print '-'*60
@@ -153,7 +157,7 @@ class Session:
                        if key == "zPosition":
                                z = int(value)
 
-               dlg.instance = eWindow(self.desktop, -z)
+               dlg.instance = eWindow(self.desktop, z)
                applyAllAttributes(dlg.instance, self.desktop, dlg.skinAttributes)
                gui = GUIOutputDevice()
                gui.parent = dlg.instance
@@ -180,13 +184,13 @@ class Session:
                self.currentDialog.callback = None # would cause re-entrancy problems.
                self.execBegin()
 
-       def openWithCallback(self, callback, screen, *arguments):
-               dlg = self.open(screen, *arguments)
+       def openWithCallback(self, callback, screen, *arguments, **kwargs):
+               dlg = self.open(screen, *arguments, **kwargs)
                dlg.callback = callback
 
-       def open(self, screen, *arguments):
+       def open(self, screen, *arguments, **kwargs):
                self.pushCurrent()
-               dlg = self.currentDialog = self.instantiateDialog(screen, *arguments)
+               dlg = self.currentDialog = self.instantiateDialog(screen, *arguments, **kwargs)
                dlg.isTmp = True
                dlg.callback = None
                self.execBegin()
@@ -235,7 +239,7 @@ class VolumeControl:
                if (eDVBVolumecontrol.getInstance().isMuted()):
                        self.volMute()
                eDVBVolumecontrol.getInstance().volumeUp()
-               self.volumeDialog.instance.show()
+               self.volumeDialog.show()
                self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
                self.volSave()
                self.hideVolTimer.start(3000, True)
@@ -244,22 +248,22 @@ class VolumeControl:
                if (eDVBVolumecontrol.getInstance().isMuted()):
                        self.volMute()
                eDVBVolumecontrol.getInstance().volumeDown()
-               self.volumeDialog.instance.show()
+               self.volumeDialog.show()
                self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
                self.volSave()
                self.hideVolTimer.start(3000, True)
 
        def volHide(self):
-               self.volumeDialog.instance.hide()
+               self.volumeDialog.hide()
 
        def     volMute(self):
                eDVBVolumecontrol.getInstance().volumeToggleMute()
                self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
 
                if (eDVBVolumecontrol.getInstance().isMuted()):
-                       self.muteDialog.instance.show()
+                       self.muteDialog.show()
                else:
-                       self.muteDialog.instance.hide()
+                       self.muteDialog.hide()
 
 def runScreenTest():
        session = Session()
@@ -267,12 +271,19 @@ def runScreenTest():
        
        session.nav = Navigation()
        
-       screensToRun = wizardManager.getWizards()
+       screensToRun = [ ]
+       
+       for p in plugins.getPlugins(PluginDescriptor.WHERE_WIZARD):
+               screensToRun.append(p.__call__)
+       
+       screensToRun += wizardManager.getWizards()
+       
        screensToRun.append(Screens.InfoBar.InfoBar)
 
        def runNextScreen(session, screensToRun, *result):
                if result:
-                       quitMainloop(result)
+                       quitMainloop(*result)
+                       return
        
                screen = screensToRun[0]
                
@@ -291,6 +302,15 @@ def runScreenTest():
        
        configfile.save()
        
+       from Tools.DreamboxHardware import setFPWakeuptime
+       from time import time
+       nextRecordingTime = session.nav.RecordTimer.getNextRecordingTime()
+       if nextRecordingTime != -1:
+               if (nextRecordingTime < 330): # no time to switch box back on
+                       setFPWakeuptime(time() + 30) # so switch back on in 30 seconds
+               else:
+                       setFPWakeuptime(nextRecordingTime - (300))
+       
        session.nav.shutdown()
        
        return 0
@@ -329,7 +349,8 @@ import Components.NimManager
 # first, setup a screen
 try:
        runScreenTest()
-       plugins.getPluginList(runAutoendPlugins=True)
+
+       plugins.shutdown()
 except:
        print 'EXCEPTION IN PYTHON STARTUP CODE:'
        print '-'*60