[Ai.HD and Vali.XD controllers] GH fix
[enigma2-plugins.git] / aihdcontroler / src / comp / vhdRendMaxTemp.py
1 # -*- coding: utf-8 -*-\r
2 #\r
3 #    Maximum Temperature Renderer for Dreambox/Enigma-2\r
4 #    Coded by Vali (c)2010\r
5 #    Support: www.dreambox-tools.info\r
6 #\r
7 #\r
8 #  This plugin is licensed under the Creative Commons \r
9 #  Attribution-NonCommercial-ShareAlike 3.0 Unported License.\r
10 #  To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/\r
11 #  or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.\r
12 #\r
13 #  Alternatively, this plugin may be distributed and executed on hardware which\r
14 #  is licensed by Dream Multimedia GmbH.\r
15 #\r
16 #\r
17 #  This plugin is NOT free software. It is open source, you are allowed to\r
18 #  modify it (if you keep the license), but it may not be commercially \r
19 #  distributed other than under the conditions noted above.\r
20 #\r
21 #\r
22 #######################################################################\r
23 \r
24 from Components.VariableText import VariableText\r
25 from Components.Sensors import sensors\r
26 from Tools.HardwareInfo import HardwareInfo\r
27 from enigma import eLabel\r
28 from Renderer import Renderer\r
29 \r
30 class vhdRendMaxTemp(Renderer, VariableText):\r
31         def __init__(self):\r
32                 Renderer.__init__(self)\r
33                 VariableText.__init__(self)\r
34                 if "8000" in HardwareInfo().get_device_name() or "500" in HardwareInfo().get_device_name() or "800se" in HardwareInfo().get_device_name():\r
35                         self.ZeigeTemp = True\r
36                 else:\r
37                         self.ZeigeTemp = False\r
38         GUI_WIDGET = eLabel\r
39 \r
40         def changed(self, what):\r
41                 if not self.suspended:\r
42                         if self.ZeigeTemp:\r
43                                 maxtemp = 0\r
44                                 try:\r
45                                         templist = sensors.getSensorsList(sensors.TYPE_TEMPERATURE)\r
46                                         tempcount = len(templist)\r
47                                         for count in range(tempcount):\r
48                                                 id = templist[count]\r
49                                                 tt = sensors.getSensorValue(id)\r
50                                                 if tt > maxtemp:\r
51                                                         maxtemp = tt\r
52                                 except:\r
53                                         pass\r
54                                 self.text = str(maxtemp) + "C"\r
55                         else:\r
56                                 loada = 0\r
57                                 try:\r
58                                         out_line = open("/proc/loadavg").readline()\r
59                                         loada = out_line[:4]    \r
60                                 except:\r
61                                         pass\r
62                                 self.text = loada\r
63 \r
64         def onShow(self):\r
65                 self.suspended = False\r
66                 self.changed(None)\r
67 \r
68         def onHide(self):\r
69                 self.suspended = True\r