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 Screens.Console import Console
10 from Plugins.Plugin import PluginDescriptor
11 from Screens.ImageWizard import ImageWizard
15 class UpdatePluginMenu(Screen):
17 <screen position="200,100" size="300,250" title="Update..." >
18 <widget name="menu" position="10,10" size="290,175" scrollbarMode="showOnDemand" />
21 def __init__(self, session, args = 0):
22 self.skin = UpdatePluginMenu.skin
23 Screen.__init__(self, session)
29 list.append((_("Image-Upgrade"), "image"))
30 list.append((_("Online-Upgrade"), "upgrade"))
31 list.append((_("Advanced"), "advanced"))
33 list.append((_("Choose source"), "source"))
34 list.append((_("Packet management"), "ipkg"))
35 list.append((_("Settings"), "setup"))
37 self["menu"] = MenuList(list)
39 self["actions"] = ActionMap(["WizardActions", "DirectionActions"],
47 if (self["menu"].l.getCurrentSelection()[1] == "image"):
48 self.session.open(ImageWizard)
49 if (self["menu"].l.getCurrentSelection()[1] == "upgrade"):
50 self.session.openWithCallback(self.runUpgrade, MessageBox, _("Do you want to update your Dreambox?\nAfter pressing OK, please wait!"))
51 if (self["menu"].l.getCurrentSelection()[1] == "advanced"):
52 self.session.open(UpdatePluginMenu, 1)
54 if (self["menu"].l.getCurrentSelection()[1] == "source"):
55 self.session.open(IPKGSource)
56 elif (self["menu"].l.getCurrentSelection()[1] == "ipkg"):
57 self.session.open(Ipkg)
58 elif (self["menu"].l.getCurrentSelection()[1] == "setup"):
59 self.session.open(MessageBox, _("Function not yet implemented"), MessageBox.TYPE_ERROR)
60 def runUpgrade(self, result):
62 self.session.open(Console, ["ipkg update", "ipkg upgrade -force-defaults -force-overwrite"])
64 class IPKGSource(Screen):
66 <screen position="100,100" size="550,60" title="IPKG source" >
67 <widget name="text" position="0,0" size="550,25" font="Regular;20" />
70 def __init__(self, session, args = None):
71 self.skin = IPKGSource.skin
72 Screen.__init__(self, session)
74 fp = file('/etc/ipkg/official-feed.conf', 'r')
75 sources = fp.readlines()
78 self["text"] = Input(sources[0], maxSize=False, type=Input.TEXT)
80 self["actions"] = NumberActionMap(["WizardActions", "InputActions"],
85 "right": self.keyRight,
86 "1": self.keyNumberGlobal,
87 "2": self.keyNumberGlobal,
88 "3": self.keyNumberGlobal,
89 "4": self.keyNumberGlobal,
90 "5": self.keyNumberGlobal,
91 "6": self.keyNumberGlobal,
92 "7": self.keyNumberGlobal,
93 "8": self.keyNumberGlobal,
94 "9": self.keyNumberGlobal,
95 "0": self.keyNumberGlobal
99 fp = file('/etc/ipkg/official-feed.conf', 'w')
100 fp.write(self["text"].getText())
110 def keyNumberGlobal(self, number):
111 print "pressed", number
112 self["text"].number(number)
121 RT_VALIGN_BOTTOM = 16
123 def PacketEntryComponent(packet):
126 res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 0,250, 30, 0, RT_HALIGN_LEFT|RT_VALIGN_CENTER, packet[0]))
127 res.append((eListboxPythonMultiContent.TYPE_TEXT, 250, 0, 200, 30, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, packet[1]))
128 res.append((eListboxPythonMultiContent.TYPE_TEXT, 450, 0, 100, 30, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, packet[2]))
131 class PacketList(GUIComponent):
132 def __init__(self, list):
133 GUIComponent.__init__(self)
134 self.l = eListboxPythonMultiContent()
136 self.l.setFont(0, gFont("Regular", 20))
137 self.l.setFont(1, gFont("Regular", 18))
139 def getCurrent(self):
140 return self.l.getCurrentSelection()
142 def GUIcreate(self, parent):
143 self.instance = eListbox(parent)
144 self.instance.setContent(self.l)
145 self.instance.setItemHeight(30)
148 self.instance.setContent(None)
151 def invalidate(self):
156 <screen position="100,100" size="550,400" title="IPKG upgrade..." >
157 <widget name="list" position="0,0" size="550,400" scrollbarMode="showOnDemand" />
160 def __init__(self, session, args = None):
161 self.skin = Ipkg.skin
162 Screen.__init__(self, session)
166 self.fillPacketList()
168 self["list"] = PacketList(self.list)
170 self["actions"] = ActionMap(["WizardActions"],
177 def fillPacketList(self):
178 lines = os.popen("ipkg list", "r").readlines()
181 split = x.split(' - ')
182 packetlist.append([split[0].strip(), split[1].strip()])
184 lines = os.popen("ipkg list_installed", "r").readlines()
188 split = x.split(' - ')
189 installedlist[split[0].strip()] = split[1].strip()
193 if installedlist.has_key(x[0]):
194 if installedlist[x[0]] == x[1]:
197 status = "upgradable"
198 self.list.append(PacketEntryComponent([x[0], x[1], status]))
202 self.session.openWithCallback(self.doUpdate, MessageBox, _("Do you want to update your Dreambox?\nAfter pressing OK, please wait!"))
206 def doUpdateDelay(self):
207 lines = os.popen("ipkg update && ipkg upgrade", "r").readlines()
211 self["text"].setText(_("Updating finished. Here is the result:") + "\n\n" + string)
215 def doUpdate(self, val = False):
217 self["text"].setText(_("Updating... Please wait... This can take some minutes..."))
218 self.delayTimer.start(0, 1)
222 def UpgradeMain(session, **kwargs):
223 session.open(UpdatePluginMenu)
225 def Plugins(**kwargs):
226 return PluginDescriptor(name="Softwareupdate", description="Updates your receiver's software", icon="update.png", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=UpgradeMain)