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 self.container.execute(self.cmdlist[self.run])
48 def runFinished(self, retval):
50 if self.run != len(self.cmdlist):
51 self.container.execute(self.cmdlist[self.run])
53 str = self["text"].getText()
54 str += _("Execution finished!!");
55 self["text"].setText(str)
56 if self.finishedCallback is not None:
57 self.finishedCallback()
58 if not retval and self.closeOnSuccess:
62 if self.run == len(self.cmdlist):
65 def dataAvail(self, str):
66 self["text"].setText(self["text"].getText() + str)