Into About added date of flash receiver
[openblackhole/openblackhole-enigma2.git] / lib / python / Components / About.py
1 # -*- coding: utf-8 -*-
2 import sys, os, time
3 from Tools.HardwareInfo import HardwareInfo
4
5 def getVersionString():
6         return getImageVersionString()
7
8 def getImageVersionString():
9         try:
10                 if os.path.isfile('/var/lib/opkg/status'):
11                         st = os.stat('/var/lib/opkg/status')
12                 else:
13                         st = os.stat('/usr/lib/ipkg/status')
14                 tm = time.localtime(st.st_mtime)
15                 if tm.tm_year >= 2011:
16                         return time.strftime("%Y-%m-%d %H:%M:%S", tm)
17         except:
18                 pass
19         return _("unavailable")
20
21 def getFlashDateString():
22         try:
23                 return time.strftime(_("%Y-%m-%d %H:%M"), time.localtime(os.stat("/boot").st_ctime))
24         except:
25                 return _("unknown")
26
27 def getEnigmaVersionString():
28         import enigma
29         enigma_version = enigma.getEnigmaVersionString()
30         if '-(no branch)' in enigma_version:
31                 enigma_version = enigma_version [:-12]
32         return enigma_version
33
34 def getGStreamerVersionString():
35         import enigma
36         return enigma.getGStreamerVersionString()
37
38 def getKernelVersionString():
39         try:
40                 return open("/proc/version","r").read().split(' ', 4)[2].split('-',2)[0]
41         except:
42                 return _("unknown")
43
44 def getHardwareTypeString():
45         return HardwareInfo().get_device_string()
46
47 def getImageTypeString():
48         try:
49                 return open("/etc/issue").readlines()[-2].capitalize().strip()[:-6]
50         except:
51                 return _("undefined")
52
53 def getCPUInfoString():
54         try:
55                 cpu_count = 0
56                 for line in open("/proc/cpuinfo").readlines():
57                         line = [x.strip() for x in line.strip().split(":")]
58                         if line[0] == "system type":
59                                 processor = line[1].split()[0]
60                         if line[0] == "cpu MHz":
61                                 cpu_speed = "%1.0f" % float(line[1])
62                                 cpu_count += 1
63                 if os.path.isfile('/proc/stb/fp/temp_sensor_avs'):
64                         temperature = open("/proc/stb/fp/temp_sensor_avs").readline().replace('\n','')
65                         return "%s %s MHz (%s) %s°C" % (processor, cpu_speed, ngettext("%d core", "%d cores", cpu_count) % cpu_count, temperature)
66                 return "%s %s MHz (%s)" % (processor, cpu_speed, ngettext("%d core", "%d cores", cpu_count) % cpu_count)
67         except:
68                 return _("undefined")
69
70 def getDriverInstalledDate():
71         try:
72                 from glob import glob
73                 driver = [x.split("-")[-2:-1][0][-8:] for x in open(glob("/var/lib/opkg/info/*-dvb-modules-*.control")[0], "r") if x.startswith("Version:")][0]
74                 return  "%s-%s-%s" % (driver[:4], driver[4:6], driver[6:])
75         except:
76                 return _("unknown")
77
78 # For modules that do "from About import about"
79 about = sys.modules[__name__]