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