Tools: small optimization- change find to in
[openblackhole/openblackhole-enigma2.git] / lib / python / Tools / HardwareInfo.py
1 class HardwareInfo:
2         device_name = None
3         device_version = None
4
5         def __init__(self):
6                 if HardwareInfo.device_name is not None:
7 #                       print "using cached result"
8                         return
9
10                 HardwareInfo.device_name = "unknown"
11                 try:
12                         file = open("/proc/stb/info/model", "r")
13                         HardwareInfo.device_name = file.readline().strip()
14                         file.close()
15                         try:
16                                 file = open("/proc/stb/info/version", "r")
17                                 HardwareInfo.device_version = file.readline().strip()
18                                 file.close()
19                         except:
20                                 pass
21                 except:
22                         print "----------------"
23                         print "you should upgrade to new drivers for the hardware detection to work properly"
24                         print "----------------"
25                         print "fallback to detect hardware via /proc/cpuinfo!!"
26                         try:
27                                 rd = open("/proc/cpuinfo", "r").read()
28                                 if "Brcm4380 V4.2" in rd:
29                                         HardwareInfo.device_name = "dm8000"
30                                         print "dm8000 detected!"
31                                 elif "Brcm7401 V0.0" in rd:
32                                         HardwareInfo.device_name = "dm800"
33                                         print "dm800 detected!"
34                                 elif "MIPS 4KEc V4.8" in rd:
35                                         HardwareInfo.device_name = "dm7025"
36                                         print "dm7025 detected!"
37                         except:
38                                 pass
39
40         def get_device_name(self):
41                 return HardwareInfo.device_name
42
43         def get_device_version(self):
44                 return HardwareInfo.device_version
45
46         def has_hdmi(self):
47                 return (HardwareInfo.device_name == 'dm7020hd' or HardwareInfo.device_name == 'dm800se' or HardwareInfo.device_name == 'dm500hd' or (HardwareInfo.device_name == 'dm8000' and HardwareInfo.device_version != None))