adding boxmodel in /web/about
[vuplus_dvbapp-plugin] / webinterface / src / WebComponents / Sources / About.py
1 # Parts of Code and idea  by Homey
2 from Components.Sources.Source import Source
3 from Components.Harddisk import HarddiskManager
4 from Components.NimManager import nimmanager
5 from Components.Network import iNetwork
6 from Components.About import about
7
8 from Tools.DreamboxHardware import getFPVersion
9
10 from ServiceReference import ServiceReference
11 from enigma import iServiceInformation
12
13 from Components.config import config
14
15 class About( Source):
16     
17     def __init__(self, session):
18         Source.__init__(self)
19         self.session = session
20     
21     def handleCommand(self,cmd):
22         self.result = False,"unknown command"
23         
24     def command(self):
25         list = []
26         list.append(about.getVersionString()) 
27
28
29         #Get Network Info
30         def ConvertIP(list):
31             if(len(list) == 4):
32                 retstr = "%s.%s.%s.%s" %(list[0], list[1], list[2], list[3])
33             else:
34                 retstr = "0.0.0.0"
35             return retstr
36
37         iface = "eth0"
38         list.append(iNetwork.getAdapterAttribute(iface, "dhcp"))
39         list.append(ConvertIP(iNetwork.getAdapterAttribute(iface, "ip")))
40         list.append(ConvertIP(iNetwork.getAdapterAttribute(iface, "netmask")))
41         list.append(ConvertIP(iNetwork.getAdapterAttribute(iface, "gateway")))
42
43
44         #Get FrontProcessor Version
45         fp_version = getFPVersion()
46         if fp_version is None:
47             fp_version = "?"
48         else:
49             fp_version = str(fp_version)
50         list.append(fp_version)
51
52         #Get Tuner Info
53         niminfo = ""
54         for nim in nimmanager.nimList():
55             info = nim.split(":")
56             
57             niminfo += "\n\t\t\t<e2nim>\n"
58             niminfo += "\t\t\t\t<name>%s</name>\n" %(info[0])
59             niminfo += "\t\t\t\t<type>%s</type>\n" %(info[1])
60             niminfo += "\t\t\t</e2nim>"
61             
62         list.append(niminfo)
63
64         #Get HDD Info
65         hddmgr = HarddiskManager()
66         if len(hddmgr.hdd):
67             hdddata = hddmgr.hdd[0] # TODO, list more than the first harddisc if there are more than one. but this requires many changes in the way the webif generates the responses
68             hddinfo = "\n\t\t\t<model>"+hdddata.model()+"</model>\n"
69             hddinfo += "\t\t\t<capacity>"+hdddata.capacity()+"</capacity>\n"
70             hddinfo += "\t\t\t<free>"+str(hdddata.free())+" MB</free>"
71             list.append(hddinfo)
72         else:            
73             hddinfo = "\n\t\t\t<model>N/A</model>\n"
74             hddinfo += "\t\t\t<capacity>-</capacity>\n"
75             hddinfo += "\t\t\t<free>-</free>"
76             list.append(hddinfo)
77
78         #Get Service Info
79         service = self.session.nav.getCurrentService()
80
81         if self.session.nav.getCurrentlyPlayingServiceReference() is not None:
82             Name = ServiceReference(self.session.nav.getCurrentlyPlayingServiceReference()).getServiceName()
83         else:
84             Name = "N/A"
85         list.append(Name)
86
87         if service is not None:
88             svinfo = service.info()
89             svfeinfo = service.frontendInfo()
90         else:
91             svinfo = None
92             svfeinfo = None
93
94         # Get Service Info
95         if self.session.nav.getCurrentlyPlayingServiceReference() is not None:
96             list.append(svinfo.getInfoString(iServiceInformation.sProvider))
97             
98             aspect = svinfo.getInfo(iServiceInformation.sAspect)
99             if aspect in ( 1, 2, 5, 6, 9, 0xA, 0xD, 0xE ):
100                 aspect = "4:3"
101             else:
102                 aspect = "16:9"
103             list.append(aspect)
104
105             width = svinfo and svinfo.getInfo(iServiceInformation.sVideoWidth) or -1
106             height = svinfo and svinfo.getInfo(iServiceInformation.sVideoHeight) or -1
107             videosize = "%dx%d" %(width, height)
108             list.append(videosize)
109             
110             list.append(hex(svinfo.getInfo(iServiceInformation.sNamespace)))
111
112             # Get PIDs
113             list.append(svinfo.getInfo(iServiceInformation.sVideoPID))
114             list.append(svinfo.getInfo(iServiceInformation.sAudioPID))
115             list.append(svinfo.getInfo(iServiceInformation.sPCRPID))
116             list.append(svinfo.getInfo(iServiceInformation.sPMTPID))
117             list.append(svinfo.getInfo(iServiceInformation.sTXTPID))
118             list.append(svinfo.getInfo(iServiceInformation.sTSID))
119             list.append(svinfo.getInfo(iServiceInformation.sONID))
120             list.append(svinfo.getInfo(iServiceInformation.sSID))
121         else:
122             list.append("N/A")
123             list.append("N/A")
124             list.append("N/A")
125             list.append("N/A")
126             list.append("N/A")
127             list.append("N/A")
128             list.append("N/A")
129             list.append("N/A")
130             list.append("N/A")
131             list.append("N/A")
132             list.append("N/A")
133             list.append("N/A")
134             
135         ## webifversion
136         list.append(config.plugins.Webinterface.version.value)
137         
138         
139         #box model
140         fp = open("/proc/stb/info/model")
141         model = fp.read().lstrip().rstrip()
142         fp.close()
143         list.append(model)
144         #please remove unneeded debugoutpu while commiting #print list
145         
146         listR = []
147         listR.append(list)
148         
149         
150         return listR
151
152     text = property(command)        
153     
154     list = property(command)
155     lut = {"enigmaVersion": 0
156            ,"lanDHCP": 1
157            ,"lanIP": 2
158            ,"lanMask": 3
159            ,"lanGW": 4
160            ,"fpVersion": 5
161            ,"tunerInfo": 6
162            ,"hddInfo": 7
163            ,"serviceName": 8
164            ,"serviceProvider": 9
165            ,"serviceAspect": 10
166            ,"serviceVideosize": 11
167            ,"serviceNamespace": 12
168            ,"vPID": 13
169            ,"aPID": 14
170            ,"pcrID": 15
171            ,"pmtPID": 16
172            ,"txtPID": 17
173            ,"tsID": 18
174            ,"onID": 19
175            ,"sid": 20
176            ,"WebIfVersion": 21
177            ,"model": 22
178            }