- new automatic scan - scans everything the NIM can handle
[enigma2.git] / lib / python / Screens / Console.py
1 from enigma import eConsoleAppContainer
2 from Screens.Screen import Screen
3 from Components.ActionMap import ActionMap, NumberActionMap
4 from Components.ScrollLabel import ScrollLabel
5
6 class Console(Screen):
7         #TODO move this to skin.xml
8         skin = """
9                 <screen position="100,100" size="550,400" title="Command execution..." >
10                         <widget name="text" position="0,0" size="550,400" font="Regular;15" />
11                 </screen>"""
12                 
13         def __init__(self, session, args = None):
14                 self.skin = Console.skin
15                 Screen.__init__(self, session)
16
17                 self["text"] = ScrollLabel("")
18                 self["actions"] = ActionMap(["WizardActions", "DirectionActions"], 
19                 {
20                         "ok": self.cancel,
21                         "back": self.cancel,
22                         "up": self["text"].pageUp,
23                         "down": self["text"].pageDown
24                 }, -1)
25                 
26                 self.cmdlist = args
27                 
28                 self.container = eConsoleAppContainer()
29                 self.run = 0
30                 self.container.appClosed.get().append(self.runFinished)
31                 self.container.dataAvail.get().append(self.dataAvail)
32                 self.onLayoutFinish.append(self.startRun) # dont start before gui is finished
33
34         def startRun(self):
35                 self["text"].setText(_("Execution Progress:") + "\n\n")
36                 print "Console: executing in run", self.run, " the command:", self.cmdlist[self.run]
37                 self.container.execute(self.cmdlist[self.run])
38
39         def runFinished(self, retval):
40                 self.run += 1
41                 if self.run != len(self.cmdlist):
42                         self.container.execute(self.cmdlist[self.run])
43                 else:
44                         str = self["text"].getText()
45                         str += _("Execution finished!!");
46                         self["text"].setText(str)
47                         
48         def cancel(self):
49                 if self.run == len(self.cmdlist):
50                         self.close()
51
52         def dataAvail(self, str):
53                 self["text"].setText(self["text"].getText() + str)