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="Regular;15" />
13 def __init__(self, session, title = "Console", cmdlist = None, finishedCallback = None, closeOnSuccess = False):
14 self.skin = Console.skin
15 Screen.__init__(self, session)
17 self.finishedCallback = finishedCallback
18 self.closeOnSuccess = closeOnSuccess
20 self["text"] = ScrollLabel("")
21 self["actions"] = ActionMap(["WizardActions", "DirectionActions"],
25 "up": self["text"].pageUp,
26 "down": self["text"].pageDown
29 self.cmdlist = cmdlist
32 self.onShown.append(self.updateTitle)
34 self.container = eConsoleAppContainer()
36 self.container.appClosed.get().append(self.runFinished)
37 self.container.dataAvail.get().append(self.dataAvail)
38 self.onLayoutFinish.append(self.startRun) # dont start before gui is finished
40 def updateTitle(self):
41 self.setTitle(self.newtitle)
44 self["text"].setText(_("Execution Progress:") + "\n\n")
45 print "Console: executing in run", self.run, " the command:", self.cmdlist[self.run]
46 if self.container.execute(self.cmdlist[self.run]): #start of container application failed...
47 self.runFinished(-1) # so we must call runFinished manual
49 def runFinished(self, retval):
51 if self.run != len(self.cmdlist):
52 if self.container.execute(self.cmdlist[self.run]): #start of container application failed...
53 self.runFinished(-1) # so we must call runFinished manual
55 str = self["text"].getText()
56 str += _("Execution finished!!");
57 self["text"].setText(str)
58 if self.finishedCallback is not None:
59 self.finishedCallback()
60 if not retval and self.closeOnSuccess:
64 if self.run == len(self.cmdlist):
67 def dataAvail(self, str):
68 self["text"].setText(self["text"].getText() + str)