1 from enigma import eConsoleAppContainer
2 from Screens.Screen import Screen
3 from Components.ActionMap import ActionMap
4 from Components.ScrollLabel import ScrollLabel
7 #TODO move this to skin.xml
9 <screen position="100,100" size="550,400" title="Command execution..." >
10 <widget name="text" position="0,0" size="550,400" font="Console;14" />
13 def __init__(self, session, title = "Console", cmdlist = None, finishedCallback = None, closeOnSuccess = False):
14 Screen.__init__(self, session)
16 self.finishedCallback = finishedCallback
17 self.closeOnSuccess = closeOnSuccess
19 self["text"] = ScrollLabel("")
20 self["actions"] = ActionMap(["WizardActions", "DirectionActions"],
24 "up": self["text"].pageUp,
25 "down": self["text"].pageDown
28 self.cmdlist = cmdlist
31 self.onShown.append(self.updateTitle)
33 self.container = eConsoleAppContainer()
35 self.container.appClosed.append(self.runFinished)
36 self.container.dataAvail.append(self.dataAvail)
37 self.onLayoutFinish.append(self.startRun) # dont start before gui is finished
39 def updateTitle(self):
40 self.setTitle(self.newtitle)
43 self["text"].setText(_("Execution Progress:") + "\n\n")
44 print "Console: executing in run", self.run, " the command:", self.cmdlist[self.run]
45 if self.container.execute(self.cmdlist[self.run]): #start of container application failed...
46 self.runFinished(-1) # so we must call runFinished manual
48 def runFinished(self, retval):
50 if self.run != len(self.cmdlist):
51 if self.container.execute(self.cmdlist[self.run]): #start of container application failed...
52 self.runFinished(-1) # so we must call runFinished manual
54 str = self["text"].getText()
55 str += _("Execution finished!!");
56 self["text"].setText(str)
57 self["text"].lastPage()
58 if self.finishedCallback is not None:
59 self.finishedCallback()
60 if not retval and self.closeOnSuccess:
64 if self.run == len(self.cmdlist):
66 self.container.appClosed.remove(self.runFinished)
67 self.container.dataAvail.remove(self.dataAvail)
69 def dataAvail(self, str):
70 self["text"].setText(self["text"].getText() + str)