handle ret value of eConsoleAppContainer.execute
[vuplus_dvbapp] / lib / python / Screens / Console.py
index c2e1688..622fb44 100644 (file)
@@ -10,11 +10,12 @@ class Console(Screen):
                        <widget name="text" position="0,0" size="550,400" font="Regular;15" />
                </screen>"""
                
-       def __init__(self, session, title = "Console", cmdlist = None, finishedCallback = None):
+       def __init__(self, session, title = "Console", cmdlist = None, finishedCallback = None, closeOnSuccess = False):
                self.skin = Console.skin
                Screen.__init__(self, session)
 
                self.finishedCallback = finishedCallback
+               self.closeOnSuccess = closeOnSuccess
 
                self["text"] = ScrollLabel("")
                self["actions"] = ActionMap(["WizardActions", "DirectionActions"], 
@@ -42,19 +43,23 @@ class Console(Screen):
        def startRun(self):
                self["text"].setText(_("Execution Progress:") + "\n\n")
                print "Console: executing in run", self.run, " the command:", self.cmdlist[self.run]
-               self.container.execute(self.cmdlist[self.run])
+               if self.container.execute(self.cmdlist[self.run]): #start of container application failed...
+                       self.runFinished(-1) # so we must call runFinished manual
 
        def runFinished(self, retval):
                self.run += 1
                if self.run != len(self.cmdlist):
-                       self.container.execute(self.cmdlist[self.run])
+                       if self.container.execute(self.cmdlist[self.run]): #start of container application failed...
+                               self.runFinished(-1) # so we must call runFinished manual
                else:
                        str = self["text"].getText()
                        str += _("Execution finished!!");
                        self["text"].setText(str)
                        if self.finishedCallback is not None:
                                self.finishedCallback()
-                       
+                       if not retval and self.closeOnSuccess:
+                               self.cancel()
+
        def cancel(self):
                if self.run == len(self.cmdlist):
                        self.close()