X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/4f46a90d789f28eb0ca156caeb2bb55136d8ac85..54793ace496ded3d53d02ee6249f0695185ad337:/lib/python/Plugins/update/plugin.py diff --git a/lib/python/Plugins/update/plugin.py b/lib/python/Plugins/update/plugin.py index 7942821c..a25eeb7e 100644 --- a/lib/python/Plugins/update/plugin.py +++ b/lib/python/Plugins/update/plugin.py @@ -2,31 +2,167 @@ from enigma import * from Screens.Screen import Screen from Screens.MessageBox import MessageBox from Components.ActionMap import ActionMap -from Components.Label import Label +from Components.ScrollLabel import ScrollLabel +from Components.GUIComponent import * +from Components.MenuList import MenuList +from Plugins.Plugin import PluginDescriptor import os -class Example(Screen): +class UpdatePluginMenu(Screen): + skin = """ + + + """ + + def __init__(self, session, args = None): + self.skin = UpdatePluginMenu.skin + Screen.__init__(self, session) + + list = [] + list.append((_("Upgrade"), "upgrade")) + list.append((_("Choose source"), None)) + list.append((_("Packet management"), "ipkg")) + + self["menu"] = MenuList(list) + + self["actions"] = ActionMap(["WizardActions", "DirectionActions"], + { + "ok": self.go, + "back": self.close, + }, -1) + + def go(self): + if (self["menu"].l.getCurrentSelection()[1] == "upgrade"): + self.session.openWithCallback(self.runUpgrade, MessageBox, _("Do you want to update your Dreambox?\nAfter pressing OK, please wait!")) + elif (self["menu"].l.getCurrentSelection()[1] == "ipkg"): + self.session.open(Ipkg) + + def runUpgrade(self, result): + if result: + self.session.open(Upgrade) + +class Upgrade(Screen): skin = """ """ def __init__(self, session, args = None): - self.skin = Example.skin + self.skin = Upgrade.skin Screen.__init__(self, session) - self["text"] = Label(_("Please press OK!")) + self["text"] = ScrollLabel(_("Updating... Please wait... This can take some minutes...")) - self["actions"] = ActionMap(["WizardActions"], + self["actions"] = ActionMap(["WizardActions", "DirectionActions"], { "ok": self.go, - "back": self.close + "back": self.close, + "up": self["text"].pageUp, + "down": self["text"].pageDown }, -1) - self.update = True self.delayTimer = eTimer() self.delayTimer.timeout.get().append(self.doUpdateDelay) + # WARNING! Don't copy this code! this code could harm your children! It is ugly, bad and must be banned from this world! + # it only exists due to some lack of competence by the core system designers. + self.delayTimer.start(1, 1) + + def go(self): + self.close() + + def doUpdateDelay(self): + lines = os.popen("ipkg update && ipkg upgrade -force-defaults -force-overwrite", "r").readlines() + string = "" + for x in lines: + string += x + self["text"].setText(_("Updating finished. Here is the result:") + "\n\n" + string) + +RT_HALIGN_LEFT = 0 +RT_HALIGN_RIGHT = 1 +RT_HALIGN_CENTER = 2 +RT_HALIGN_BLOCK = 4 + +RT_VALIGN_TOP = 0 +RT_VALIGN_CENTER = 8 +RT_VALIGN_BOTTOM = 16 + +def PacketEntryComponent(packet): + res = [ packet ] + + res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 0,250, 30, 0, RT_HALIGN_LEFT|RT_VALIGN_CENTER, packet[0])) + res.append((eListboxPythonMultiContent.TYPE_TEXT, 250, 0, 200, 30, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, packet[1])) + res.append((eListboxPythonMultiContent.TYPE_TEXT, 450, 0, 100, 30, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, packet[2])) + return res + +class PacketList(GUIComponent): + def __init__(self, list): + GUIComponent.__init__(self) + self.l = eListboxPythonMultiContent() + self.l.setList(list) + self.l.setFont(0, gFont("Regular", 20)) + self.l.setFont(1, gFont("Regular", 18)) + + def getCurrent(self): + return self.l.getCurrentSelection() + + def GUIcreate(self, parent): + self.instance = eListbox(parent) + self.instance.setContent(self.l) + self.instance.setItemHeight(30) + + def GUIdelete(self): + self.instance.setContent(None) + self.instance = None + + def invalidate(self): + self.l.invalidate() + +class Ipkg(Screen): + skin = """ + + + """ + + def __init__(self, session, args = None): + self.skin = Ipkg.skin + Screen.__init__(self, session) + + list = [] + self.list = list + self.fillPacketList() + + self["list"] = PacketList(self.list) + + self["actions"] = ActionMap(["WizardActions"], + { + "ok": self.close, + "back": self.close + }, -1) + + + def fillPacketList(self): + lines = os.popen("ipkg list", "r").readlines() + packetlist = [] + for x in lines: + split = x.split(' - ') + packetlist.append([split[0].strip(), split[1].strip()]) + + lines = os.popen("ipkg list_installed", "r").readlines() + + installedlist = {} + for x in lines: + split = x.split(' - ') + installedlist[split[0].strip()] = split[1].strip() + + for x in packetlist: + status = "" + if installedlist.has_key(x[0]): + if installedlist[x[0]] == x[1]: + status = "installed" + else: + status = "upgradable" + self.list.append(PacketEntryComponent([x[0], x[1], status])) def go(self): if self.update: @@ -48,21 +184,10 @@ class Example(Screen): self["text"].setText(_("Updating... Please wait... This can take some minutes...")) self.delayTimer.start(0, 1) else: - self.close() - -#def autostart(): - #print "**************************** AUTOSTART" -# -#def autoend(): - #print "**************************** AUTOEND" + self.close() -def getPicturePaths(): - return ["update.png"] +def UpgradeMain(session): + session.open(UpdatePluginMenu) -def getPlugins(): - return [("Softwareupdate", "Updates your receiver's software", "screen", "Example")] - -def getMenuRegistrationList(): - list = [] - list.append(("setup", 2, "Softwareupdate", "Example")) - return list \ No newline at end of file +def Plugins(): + return PluginDescriptor(name="Softwareupdate", description="Updates your receiver's software", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=UpgradeMain)