recursively search for plugins
[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                 self.container.execute(self.cmdlist[self.run])
37
38         def runFinished(self, retval):
39                 self.run += 1
40                 if self.run != len(self.cmdlist):
41                         self.container.execute(self.cmdlist[self.run])
42                 else:
43                         str = self["text"].getText()
44                         str += _("Execution finished!!");
45                         self["text"].setText(str)
46                         
47         def cancel(self):
48                 if self.run == len(self.cmdlist):
49                         self.close()
50
51         def dataAvail(self, str):
52                 self["text"].setText(self["text"].getText() + str)