2 from Screens.Screen import Screen
3 from Screens.MessageBox import MessageBox
4 from Components.ActionMap import ActionMap, NumberActionMap
5 from Components.ScrollLabel import ScrollLabel
6 from Components.GUIComponent import *
7 from Components.MenuList import MenuList
8 from Components.Input import Input
9 from Plugins.Plugin import PluginDescriptor
13 class UpdatePluginMenu(Screen):
15 <screen position="200,100" size="300,250" title="Update..." >
16 <widget name="menu" position="10,10" size="290,175" scrollbarMode="showOnDemand" />
19 def __init__(self, session, args = None):
20 self.skin = UpdatePluginMenu.skin
21 Screen.__init__(self, session)
24 list.append((_("Upgrade"), "upgrade"))
25 list.append((_("Choose source"), "source"))
26 list.append((_("Packet management"), "ipkg"))
28 self["menu"] = MenuList(list)
30 self["actions"] = ActionMap(["WizardActions", "DirectionActions"],
37 if (self["menu"].l.getCurrentSelection()[1] == "upgrade"):
38 self.session.openWithCallback(self.runUpgrade, MessageBox, _("Do you want to update your Dreambox?\nAfter pressing OK, please wait!"))
39 elif (self["menu"].l.getCurrentSelection()[1] == "source"):
40 self.session.open(IPKGSource)
41 elif (self["menu"].l.getCurrentSelection()[1] == "ipkg"):
42 self.session.open(Ipkg)
44 def runUpgrade(self, result):
46 self.session.open(Upgrade)
48 class IPKGSource(Screen):
50 <screen position="100,100" size="550,60" title="IPKG source" >
51 <widget name="text" position="0,0" size="550,25" font="Regular;20" />
54 def __init__(self, session, args = None):
55 self.skin = IPKGSource.skin
56 Screen.__init__(self, session)
58 fp = file('/etc/ipkg/official-feed.conf', 'r')
59 sources = fp.readlines()
62 self["text"] = Input(sources[0], maxSize=False, type=Input.TEXT)
64 self["actions"] = NumberActionMap(["WizardActions", "InputActions"],
69 "right": self.keyRight,
70 "1": self.keyNumberGlobal,
71 "2": self.keyNumberGlobal,
72 "3": self.keyNumberGlobal,
73 "4": self.keyNumberGlobal,
74 "5": self.keyNumberGlobal,
75 "6": self.keyNumberGlobal,
76 "7": self.keyNumberGlobal,
77 "8": self.keyNumberGlobal,
78 "9": self.keyNumberGlobal,
79 "0": self.keyNumberGlobal
83 fp = file('/etc/ipkg/official-feed.conf', 'w')
84 fp.write(self["text"].getText())
94 def keyNumberGlobal(self, number):
95 print "pressed", number
96 self["text"].number(number)
98 class Upgrade(Screen):
100 <screen position="100,100" size="550,400" title="IPKG upgrade..." >
101 <widget name="text" position="0,0" size="550,400" font="Regular;15" />
104 def __init__(self, session, args = None):
105 self.skin = Upgrade.skin
106 Screen.__init__(self, session)
108 self["text"] = ScrollLabel(_("Updating... Please wait... This can take some minutes..."))
110 self["actions"] = ActionMap(["WizardActions", "DirectionActions"],
114 "up": self["text"].pageUp,
115 "down": self["text"].pageDown
118 self.delayTimer = eTimer()
119 self.delayTimer.timeout.get().append(self.doUpdateDelay)
120 # WARNING! Don't copy this code! this code could harm your children! It is ugly, bad and must be banned from this world!
121 # it only exists due to some lack of competence by the core system designers.
122 self.delayTimer.start(1, 1)
127 def doUpdateDelay(self):
128 lines = os.popen("ipkg update && ipkg upgrade -force-defaults -force-overwrite", "r").readlines()
132 self["text"].setText(_("Updating finished. Here is the result:") + "\n\n" + string)
141 RT_VALIGN_BOTTOM = 16
143 def PacketEntryComponent(packet):
146 res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 0,250, 30, 0, RT_HALIGN_LEFT|RT_VALIGN_CENTER, packet[0]))
147 res.append((eListboxPythonMultiContent.TYPE_TEXT, 250, 0, 200, 30, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, packet[1]))
148 res.append((eListboxPythonMultiContent.TYPE_TEXT, 450, 0, 100, 30, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, packet[2]))
151 class PacketList(GUIComponent):
152 def __init__(self, list):
153 GUIComponent.__init__(self)
154 self.l = eListboxPythonMultiContent()
156 self.l.setFont(0, gFont("Regular", 20))
157 self.l.setFont(1, gFont("Regular", 18))
159 def getCurrent(self):
160 return self.l.getCurrentSelection()
162 def GUIcreate(self, parent):
163 self.instance = eListbox(parent)
164 self.instance.setContent(self.l)
165 self.instance.setItemHeight(30)
168 self.instance.setContent(None)
171 def invalidate(self):
176 <screen position="100,100" size="550,400" title="IPKG upgrade..." >
177 <widget name="list" position="0,0" size="550,400" scrollbarMode="showOnDemand" />
180 def __init__(self, session, args = None):
181 self.skin = Ipkg.skin
182 Screen.__init__(self, session)
186 self.fillPacketList()
188 self["list"] = PacketList(self.list)
190 self["actions"] = ActionMap(["WizardActions"],
197 def fillPacketList(self):
198 lines = os.popen("ipkg list", "r").readlines()
201 split = x.split(' - ')
202 packetlist.append([split[0].strip(), split[1].strip()])
204 lines = os.popen("ipkg list_installed", "r").readlines()
208 split = x.split(' - ')
209 installedlist[split[0].strip()] = split[1].strip()
213 if installedlist.has_key(x[0]):
214 if installedlist[x[0]] == x[1]:
217 status = "upgradable"
218 self.list.append(PacketEntryComponent([x[0], x[1], status]))
222 self.session.openWithCallback(self.doUpdate, MessageBox, _("Do you want to update your Dreambox?\nAfter pressing OK, please wait!"))
226 def doUpdateDelay(self):
227 lines = os.popen("ipkg update && ipkg upgrade", "r").readlines()
231 self["text"].setText(_("Updating finished. Here is the result:") + "\n\n" + string)
235 def doUpdate(self, val = False):
237 self["text"].setText(_("Updating... Please wait... This can take some minutes..."))
238 self.delayTimer.start(0, 1)
242 def UpgradeMain(session):
243 session.open(UpdatePluginMenu)
246 return PluginDescriptor(name="Softwareupdate", description="Updates your receiver's software", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=UpgradeMain)