67501b17f7be90245667f9a98e5f15fe7f0e1e10
[enigma2.git] / lib / python / Plugins / SystemPlugins / FrontprocessorUpgrade / plugin.py
1 from Screens.Screen import Screen
2 from Components.ActionMap import ActionMap
3 from Components.Label import Label
4 from Plugins.Plugin import PluginDescriptor
5
6 def getUpgradeVersion():
7         import os
8         try:
9                 r = os.popen("fpupgrade --version").read()
10         except IOError:
11                 return None
12         if r[:16] != "FP update tool v":
13                 return None
14         else:
15                 return int(r[16:17])
16
17 class FPUpgrade(Screen):
18         skin = """
19                 <screen position="150,200" size="450,200" title="FP upgrade required" >
20                         <widget name="text" position="0,0" size="550,50" font="Regular;20" />
21                         <widget name="oldversion_label" position="10,100" size="290,25" font="Regular;20" />
22                         <widget name="newversion_label" position="10,125" size="290,25" font="Regular;20" />
23                         <widget name="oldversion" position="300,100" size="50,25" font="Regular;20" />
24                         <widget name="newversion" position="300,125" size="50,25" font="Regular;20" />
25                 </screen>"""
26         def __init__(self, session):
27                 self.skin = FPUpgrade.skin
28                 Screen.__init__(self, session)
29                 
30                 from Tools.DreamboxHardware import getFPVersion
31                 version = str(getFPVersion() or "N/A")
32                 newversion = str(getUpgradeVersion() or "N/A")
33
34                 self["text"] = Label(_("Your frontprocessor firmware must be upgraded.\nPress OK to start upgrade."))
35                 self["oldversion_label"] = Label(_("Current version:"))
36                 self["newversion_label"] = Label(_("New version:"))
37
38                 self["oldversion"] = Label(version)
39                 self["newversion"] = Label(newversion)
40
41                 self["actions"] = ActionMap(["OkCancelActions"],
42                 {
43                         "ok": self.ok,
44                         "cancel": self.close,
45                 })
46
47         def ok(self):
48                 self.close(4)
49
50 def Plugins(**kwargs):
51         from Tools.DreamboxHardware import getFPVersion
52         version = getFPVersion()
53         newversion = getUpgradeVersion() or 0
54         if version is not None and version < newversion:
55                 return PluginDescriptor(name="FP Upgrade", where = PluginDescriptor.WHERE_WIZARD, fnc=(8, FPUpgrade))
56         else:
57                 return [ ]