Introduce getGStreamerVersionString function and use it in About screen
[openblackhole/openblackhole-enigma2.git] / lib / python / Components / About.py
1 import sys
2 import os
3 import time
4 from Tools.HardwareInfo import HardwareInfo
5
6 def getVersionString():
7         return getImageVersionString()
8
9 def getImageVersionString():
10         try:
11                 if os.path.isfile('/var/lib/opkg/status'):
12                         st = os.stat('/var/lib/opkg/status')
13                 else:
14                         st = os.stat('/usr/lib/ipkg/status')
15                 tm = time.localtime(st.st_mtime)
16                 if tm.tm_year >= 2011:
17                         return time.strftime("%Y-%m-%d %H:%M:%S", tm)
18         except:
19                 pass
20         return _("unavailable")
21
22 def getEnigmaVersionString():
23         import enigma
24         enigma_version = enigma.getEnigmaVersionString()
25         if '-(no branch)' in enigma_version:
26                 enigma_version = enigma_version [:-12]
27         return enigma_version
28
29 def getGStreamerVersionString():
30         import enigma
31         return enigma.getGStreamerVersionString()
32
33 def getKernelVersionString():
34         try:
35                 return open("/proc/version","r").read().split(' ', 4)[2].split('-',2)[0]
36         except:
37                 return _("unknown")
38
39 def getHardwareTypeString():
40         return HardwareInfo().get_device_string()
41
42 def getImageTypeString():
43         try:
44                 return open("/etc/issue").readlines()[-2].capitalize().strip()[:-6]
45         except:
46                 return _("undefined")
47
48 def getCPUInfoString():
49         try:
50                 cpu_count = 0
51                 for line in open("/proc/cpuinfo").readlines():
52                         line = [x.strip() for x in line.strip().split(":")]
53                         if line[0] == "system type":
54                                 processor = line[1].split()[0]
55                         if line[0] == "cpu MHz":
56                                 cpu_speed = "%1.0f" % float(line[1])
57                                 cpu_count += 1
58                 return "%s %s MHz (%d %s)" % (processor, cpu_speed, cpu_count, cpu_count > 1 and "cores" or "core")
59         except:
60                 return _("undefined")
61
62 # For modules that do "from About import about"
63 about = sys.modules[__name__]