small fix
[enigma2.git] / mytest.py
index 9587273a3dc1bc9f912ef4ff7f6495e1025bd6bd..5bc08914afdab5ad1170ae8f1ce3fee90df9c939 100644 (file)
--- a/mytest.py
+++ b/mytest.py
@@ -1,5 +1,6 @@
 from Tools import RedirectOutput
-from enigma import *
+from enigma import runMainloop, eDVBDB, eTimer, quitMainloop, eDVBVolumecontrol, \
+       getDesktop, ePythonConfigQuery, eAVSwitch, eWindow
 from tools import *
 
 from Components.Language import language
@@ -10,12 +11,11 @@ def setEPGLanguage():
        
 language.addCallback(setEPGLanguage)
 
-import traceback
+from traceback import print_exc
 import Screens.InfoBar
 from Screens.SimpleSummary import SimpleSummary
 
-import sys
-import time
+from sys import stdout, exc_info
 
 import ServiceReference
 
@@ -27,7 +27,7 @@ from Navigation import Navigation
 from skin import readSkin, applyAllAttributes
 
 from Tools.Directories import InitFallbackFiles, resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE
-from Components.config import config, ConfigText, configfile, ConfigSubsection, ConfigInteger
+from Components.config import config, configfile, ConfigText, ConfigSubsection, ConfigInteger
 InitFallbackFiles()
 eDVBDB.getInstance().reloadBouquets()
 
@@ -191,9 +191,9 @@ class Session:
                try:
                        return screen(self, *arguments, **kwargs)
                except:
-                       errstr = "Screen %s(%s, %s): %s" % (str(screen), str(arguments), str(kwargs), sys.exc_info()[0])
+                       errstr = "Screen %s(%s, %s): %s" % (str(screen), str(arguments), str(kwargs), exc_info()[0])
                        print errstr
-                       traceback.print_exc(file=sys.stdout)
+                       print_exc(file=stdout)
                        quitMainloop(5)
        
        def instantiateDialog(self, screen, *arguments, **kwargs):
@@ -214,7 +214,7 @@ class Session:
                except:
                        print 'EXCEPTION IN DIALOG INIT CODE, ABORTING:'
                        print '-'*60
-                       traceback.print_exc(file=sys.stdout)
+                       print_exc(file=stdout)
                        quitMainloop(5)
                        print '-'*60
                
@@ -387,7 +387,7 @@ class VolumeControl:
                                self.muteDialog.hide()
                                self.volumeDialog.setValue(vol)
 
-from Screens.Standby import Standby
+from Screens.Standby import Standby, TryQuitMainloop, inTryQuitMainloop
 
 class PowerKey:
        """ PowerKey stuff - handles the powerkey press and powerkey release actions"""
@@ -409,7 +409,9 @@ class PowerKey:
 
        def powertimer(self):   
                print "PowerOff - Now!"
-               self.quit()
+               global inTryQuitMainloop
+               if not inTryQuitMainloop:
+                       self.session.open(TryQuitMainloop, 1)
        
        def powerdown(self):
                self.standbyblocked = 0
@@ -423,11 +425,7 @@ class PowerKey:
 
        def standby(self):
                if self.session.current_dialog and self.session.current_dialog.ALLOW_SUSPEND:
-                       self.session.open(Standby, self)
-
-       def quit(self):
-               # halt
-               quitMainloop(1)
+                       self.session.open(Standby)
 
 from Screens.Scart import Scart
 
@@ -489,13 +487,13 @@ def runScreenTest():
 
        # we need session.scart to access it from within menu.xml
        session.scart = AutoScartControl(session)
-       
+
        runReactor()
        
        configfile.save()
-       
-       from Tools.DreamboxHardware import setFPWakeuptime
+
        from time import time
+       from Tools.DreamboxHardware import setFPWakeuptime
        nextRecordingTime = session.nav.RecordTimer.getNextRecordingTime()
        if nextRecordingTime != -1:
                if (nextRecordingTime - time() < 330): # no time to switch box back on
@@ -553,6 +551,6 @@ try:
 except:
        print 'EXCEPTION IN PYTHON STARTUP CODE:'
        print '-'*60
-       traceback.print_exc(file=sys.stdout)
+       print_exc(file=stdout)
        quitMainloop(5)
        print '-'*60