SoftwareManager/plugin.py: - enable extensions management inside Software manager.
[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 class SystemMessage(Screen):
51         skin = """
52                 <screen position="150,200" size="450,200" title="System Message" >
53                         <widget source="text" position="0,0" size="450,200" font="Regular;20" halign="center" valign="center" render="Label" />
54                         <ePixmap pixmap="skin_default/icons/input_error.png" position="5,5" size="53,53" alphatest="on" />
55                 </screen>"""
56         def __init__(self, session, message):
57                 from Components.Sources.StaticText import StaticText
58
59                 Screen.__init__(self, session)
60
61                 self["text"] = StaticText(message)
62
63                 self["actions"] = ActionMap(["OkCancelActions"],
64                 {
65                         "cancel": self.ok,
66                 })
67
68         def ok(self):
69                 self.close()
70
71 def Plugins(**kwargs):
72         from Tools.DreamboxHardware import getFPVersion
73         from Screens.MessageBox import MessageBox
74
75         version = getFPVersion()
76         newversion = getUpgradeVersion() or 0
77         list = []
78         if version is not None and version < newversion:
79                 list.append(PluginDescriptor(name="FP Upgrade", where = PluginDescriptor.WHERE_WIZARD, fnc=(8, FPUpgrade)))
80
81         try:
82                 msg = open("/proc/stb/message").read()
83                 list.append(PluginDescriptor(name="System Message Check", where = PluginDescriptor.WHERE_WIZARD, fnc=(9, SystemMessage, msg)))
84         except:
85                 pass
86
87         return list