7942821c6ad777682d01e3456f9d4d69167decfe
[enigma2.git] / lib / python / Plugins / update / plugin.py
1 from enigma import *
2 from Screens.Screen import Screen
3 from Screens.MessageBox import MessageBox
4 from Components.ActionMap import ActionMap
5 from Components.Label import Label
6
7 import os
8
9 class Example(Screen):
10         skin = """
11                 <screen position="100,100" size="550,400" title="IPKG upgrade..." >
12                         <widget name="text" position="0,0" size="550,400" font="Regular;15" />
13                 </screen>"""
14                 
15         def __init__(self, session, args = None):
16                 self.skin = Example.skin
17                 Screen.__init__(self, session)
18
19                 self["text"] = Label(_("Please press OK!"))
20                                 
21                 self["actions"] = ActionMap(["WizardActions"], 
22                 {
23                         "ok": self.go,
24                         "back": self.close
25                 }, -1)
26                 
27                 self.update = True
28                 self.delayTimer = eTimer()
29                 self.delayTimer.timeout.get().append(self.doUpdateDelay)
30                 
31         def go(self):
32                 if self.update:
33                         self.session.openWithCallback(self.doUpdate, MessageBox, _("Do you want to update your Dreambox?\nAfter pressing OK, please wait!"))            
34                 else:
35                         self.close()
36         
37         def doUpdateDelay(self):
38                 lines = os.popen("ipkg update && ipkg upgrade", "r").readlines()
39                 string = ""
40                 for x in lines:
41                         string += x
42                 self["text"].setText(_("Updating finished. Here is the result:") + "\n\n" + string)
43                 self.update = False
44                         
45         
46         def doUpdate(self, val = False):
47                 if val == True:
48                         self["text"].setText(_("Updating... Please wait... This can take some minutes..."))
49                         self.delayTimer.start(0, 1)
50                 else:
51                         self.close()            
52                 
53 #def autostart():
54         #print "**************************** AUTOSTART"
55 #
56 #def autoend():
57         #print "**************************** AUTOEND"
58
59 def getPicturePaths():
60         return ["update.png"]
61
62 def getPlugins():
63         return [("Softwareupdate", "Updates your receiver's software", "screen", "Example")]
64         
65 def getMenuRegistrationList():
66         list = []
67         list.append(("setup", 2, "Softwareupdate", "Example"))
68         return list