1 from Components.ActionMap import ActionMap
2 from Components.Ipkg import IpkgComponent
3 from Components.Label import Label
4 from Components.Slider import Slider
5 from Screens.Screen import Screen
6 from Screens.MessageBox import MessageBox
7 from enigma import eTimer
10 def __init__(self, session, cmdList = []):
11 Screen.__init__(self, session)
13 self.cmdList = cmdList
15 self.sliderPackages = {}
17 self.slider = Slider(0, len(cmdList))
18 self["slider"] = self.slider
19 self.activityslider = Slider(0, 100)
20 self["activityslider"] = self.activityslider
21 self.status = Label(_("Preparing... Please wait"))
22 self["status"] = self.status
23 self.package = Label()
24 self["package"] = self.package
30 self.activityTimer = eTimer()
31 self.activityTimer.timeout.get().append(self.doActivityTimer)
32 #self.activityTimer.start(100, False)
34 self.ipkg = IpkgComponent()
35 self.ipkg.addCallback(self.ipkgCallback)
37 self.runningCmd = None
40 self["actions"] = ActionMap(["WizardActions"],
47 if self.runningCmd is None:
51 print len(self.cmdList), self.runningCmd
52 if len(self.cmdList) - 1 < self.runningCmd:
53 self.activityslider.setValue(0)
54 self.slider.setValue(len(self.cmdList))
56 self.package.setText("")
57 self.status.setText(_("Done - Installed or upgraded %d packages with %d errors") % (self.packages, self.error))
60 cmd = self.cmdList[self.runningCmd]
61 self.slider.setValue(self.runningCmd)
62 self.ipkg.startCmd(cmd[0], args = cmd[1])
63 self.startActivityTimer()
65 def doActivityTimer(self):
66 if not self.ipkg.isRunning():
67 self.stopActivityTimer()
70 if self.activity == 100:
72 self.activityslider.setValue(self.activity)
74 def startActivityTimer(self):
75 self.activityTimer.start(100, False)
77 def stopActivityTimer(self):
78 self.activityTimer.stop()
80 def ipkgCallback(self, event, param):
81 if event == IpkgComponent.EVENT_DOWNLOAD:
82 self.status.setText(_("Downloading"))
83 elif event == IpkgComponent.EVENT_UPGRADE:
84 if self.sliderPackages.has_key(param):
85 self.slider.setValue(self.sliderPackages[param])
86 self.package.setText(param)
87 self.status.setText(_("Upgrading"))
89 elif event == IpkgComponent.EVENT_INSTALL:
90 self.package.setText(param)
91 self.status.setText(_("Installing"))
93 elif event == IpkgComponent.EVENT_CONFIGURING:
94 self.package.setText(param)
95 self.status.setText(_("Configuring"))
96 elif event == IpkgComponent.EVENT_ERROR:
98 elif event == IpkgComponent.EVENT_DONE:
100 elif event == IpkgComponent.EVENT_MODIFIED:
101 self.session.openWithCallback(
102 self.modificationCallback,
104 _("A configuration file (%s) was modified since Installation.\nDo you want to keep your version?") % (param)
107 def modificationCallback(self, res):
108 self.ipkg.write(res and "N" or "Y")
111 if not self.ipkg.isRunning():