X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fpython%2FScreens%2FConsole.py;h=622fb447973d76005d738a90546bc3077d3c2c64;hp=dbe2fe9e5125241682900cc11e4ee960422be093;hb=e74488aadbdfd34aea53166c9447016f3fa3ac29;hpb=3ad1f5540aa20e5b8132ededc367d8f319b2d5dd diff --git a/lib/python/Screens/Console.py b/lib/python/Screens/Console.py index dbe2fe9..622fb44 100644 --- a/lib/python/Screens/Console.py +++ b/lib/python/Screens/Console.py @@ -1,6 +1,6 @@ from enigma import eConsoleAppContainer from Screens.Screen import Screen -from Components.ActionMap import ActionMap, NumberActionMap +from Components.ActionMap import ActionMap from Components.ScrollLabel import ScrollLabel class Console(Screen): @@ -10,10 +10,13 @@ class Console(Screen): """ - def __init__(self, session, args = 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"], { @@ -23,7 +26,10 @@ class Console(Screen): "down": self["text"].pageDown }, -1) - self.cmdlist = args + self.cmdlist = cmdlist + self.newtitle = title + + self.onShown.append(self.updateTitle) self.container = eConsoleAppContainer() self.run = 0 @@ -31,22 +37,32 @@ class Console(Screen): self.container.dataAvail.get().append(self.dataAvail) self.onLayoutFinish.append(self.startRun) # dont start before gui is finished + def updateTitle(self): + self.setTitle(self.newtitle) + def startRun(self): self["text"].setText(_("Execution Progress:") + "\n\n") - self.container.execute(self.cmdlist[self.run]) + print "Console: executing in run", self.run, " the command:", 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() def dataAvail(self, str): - self["text"].setText(self["text"].getText() + str) \ No newline at end of file + self["text"].setText(self["text"].getText() + str)