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
28 self.processed_packages = []
31 self.activityTimer = eTimer()
32 self.activityTimer.callback.append(self.doActivityTimer)
33 #self.activityTimer.start(100, False)
35 self.ipkg = IpkgComponent()
36 self.ipkg.addCallback(self.ipkgCallback)
38 self.runningCmd = None
41 self["actions"] = ActionMap(["WizardActions"],
48 if self.runningCmd is None:
52 print len(self.cmdList), self.runningCmd
53 if len(self.cmdList) - 1 < self.runningCmd:
54 self.activityslider.setValue(0)
55 self.slider.setValue(len(self.cmdList))
57 self.package.setText("")
58 self.status.setText(_("Done - Installed, upgraded or removed %d packages with %d errors") % (self.packages, self.error))
61 cmd = self.cmdList[self.runningCmd]
62 self.slider.setValue(self.runningCmd)
63 self.ipkg.startCmd(cmd[0], args = cmd[1])
64 self.startActivityTimer()
66 def doActivityTimer(self):
67 if not self.ipkg.isRunning():
68 self.stopActivityTimer()
71 if self.activity == 100:
73 self.activityslider.setValue(self.activity)
75 def startActivityTimer(self):
76 self.activityTimer.start(100, False)
78 def stopActivityTimer(self):
79 self.activityTimer.stop()
81 def ipkgCallback(self, event, param):
82 if event == IpkgComponent.EVENT_DOWNLOAD:
83 self.status.setText(_("Downloading"))
84 elif event == IpkgComponent.EVENT_UPGRADE:
85 if self.sliderPackages.has_key(param):
86 self.slider.setValue(self.sliderPackages[param])
87 self.package.setText(param)
88 self.status.setText(_("Upgrading"))
89 if not param in self.processed_packages:
90 self.processed_packages.append(param)
92 elif event == IpkgComponent.EVENT_INSTALL:
93 self.package.setText(param)
94 self.status.setText(_("Installing"))
95 if not param in self.processed_packages:
96 self.processed_packages.append(param)
98 elif event == IpkgComponent.EVENT_REMOVE:
99 self.package.setText(param)
100 self.status.setText(_("Removing"))
101 if not param in self.processed_packages:
102 self.processed_packages.append(param)
104 elif event == IpkgComponent.EVENT_CONFIGURING:
105 self.package.setText(param)
106 self.status.setText(_("Configuring"))
107 elif event == IpkgComponent.EVENT_ERROR:
109 elif event == IpkgComponent.EVENT_DONE:
111 elif event == IpkgComponent.EVENT_MODIFIED:
112 self.session.openWithCallback(
113 self.modificationCallback,
115 _("A configuration file (%s) was modified since Installation.\nDo you want to keep your version?") % (param)
118 def modificationCallback(self, res):
119 self.ipkg.write(res and "N" or "Y")
122 if not self.ipkg.isRunning():