X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/948213ba7e5d1bc6a9c4d7f5f9d35c53186b60d3..ec21f179954efe759b8975185d720be4c537bdcf:/lib/python/Plugins/SystemPlugins/SoftwareUpdate/plugin.py diff --git a/lib/python/Plugins/SystemPlugins/SoftwareUpdate/plugin.py b/lib/python/Plugins/SystemPlugins/SoftwareUpdate/plugin.py index e12729b5..19ab3eea 100644 --- a/lib/python/Plugins/SystemPlugins/SoftwareUpdate/plugin.py +++ b/lib/python/Plugins/SystemPlugins/SoftwareUpdate/plugin.py @@ -1,4 +1,4 @@ -from enigma import * +from enigma import eTimer, quitMainloop from Screens.Screen import Screen from Screens.MessageBox import MessageBox from Components.ActionMap import ActionMap, NumberActionMap @@ -10,6 +10,9 @@ from Screens.Console import Console from Screens.MessageBox import MessageBox from Plugins.Plugin import PluginDescriptor from Screens.ImageWizard import ImageWizard +from Components.Ipkg import Ipkg +from Components.Slider import Slider +from Components.Label import Label import os @@ -162,7 +165,7 @@ class PacketList(GUIComponent): def invalidate(self): self.l.invalidate() -class Ipkg(Screen): +class Ipkg2(Screen): skin = """ @@ -229,9 +232,113 @@ class Ipkg(Screen): self.delayTimer.start(0, 1) else: self.close() + +class UpdatePlugin(Screen): + skin = """ + + + + + + """ + + def __init__(self, session, args = None): + self.skin = UpdatePlugin.skin + Screen.__init__(self, session) + + self.sliderPackages = { "dreambox-dvb-modules": 1, "enigma2": 2, "tuxbox-image-info": 3 } + + self.slider = Slider(0, 4) + self["slider"] = self.slider + self.activityslider = Slider(0, 100) + self["activityslider"] = self.activityslider + self.status = Label(_("Upgrading Dreambox... Please wait")) + self["status"] = self.status + self.package = Label() + self["package"] = self.package + + self.packages = 0 + self.error = 0 + + self.activity = 0 + self.activityTimer = eTimer() + self.activityTimer.timeout.get().append(self.doActivityTimer) + self.activityTimer.start(100, False) + + self.ipkg = Ipkg() + self.ipkg.addCallback(self.ipkgCallback) + + self.updating = True + self.package.setText(_("Package list update")) + self.ipkg.cmdUpdate() + + self["actions"] = ActionMap(["WizardActions"], + { + "ok": self.exit, + "back": self.exit + }, -1) + + def doActivityTimer(self): + self.activity += 1 + if self.activity == 100: + self.activity = 0 + self.activityslider.setValue(self.activity) + + def ipkgCallback(self, event, param): + if event == Ipkg.EVENT_DOWNLOAD: + self.status.setText(_("Downloading")) + elif event == Ipkg.EVENT_UPGRADE: + if self.sliderPackages.has_key(param): + self.slider.setValue(self.sliderPackages[param]) + self.package.setText(param) + self.status.setText(_("Upgrading")) + self.packages += 1 + elif event == Ipkg.EVENT_INSTALL: + self.package.setText(param) + self.status.setText(_("Installing")) + self.packages += 1 + elif event == Ipkg.EVENT_CONFIGURING: + self.package.setText(param) + self.status.setText(_("Configuring")) + elif event == Ipkg.EVENT_ERROR: + self.error += 1 + elif event == Ipkg.EVENT_DONE: + if self.updating: + self.updating = False + self.ipkg.cmdUpgrade(test_only = False) + elif self.error == 0: + self.slider.setValue(4) + + self.activityTimer.stop() + self.activityslider.setValue(0) + + self.package.setText("") + self.status.setText(_("Done - Installed or upgraded %d packages") % self.packages) + else: + self.activityTimer.stop() + self.activityslider.setValue(0) + error = _("your dreambox might be unusable now. Please consult the manual for further assistance before rebooting your dreambox.") + if self.packages == 0: + error = _("No packages were upgraded yet. So you can check your network and try again.") + if self.updating: + error = _("Your dreambox isn't connected to the internet properly. Please check it and try again.") + self.status.setText(_("Error") + " - " + error) + #print event, "-", param + pass + + def exit(self): + if self.packages != 0 and self.error == 0: + self.session.openWithCallback(self.exitAnswer, MessageBox, _("Upgrade finished. Do you want to reboot your Dreambox?")) + else: + self.close() + + def exitAnswer(self, result): + if result is not None and result: + quitMainloop(2) + self.close() def UpgradeMain(session, **kwargs): - session.open(UpdatePluginMenu) + session.open(UpdatePlugin) def Plugins(**kwargs): - return PluginDescriptor(name="Softwareupdate", description="Updates your receiver's software", icon="update.png", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=UpgradeMain) + return PluginDescriptor(name="Softwareupdate", description=_("Updates your receiver's software"), icon="update.png", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=UpgradeMain)