rename directories to match plugin names (aihdcontrol, unwetterzentrale, vxdcontrol)
[enigma2-plugins.git] / valixdcontrol / src / comp / vRendMaxTemp.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 from os import popen\r
30 \r
31 class vRendMaxTemp(Renderer, VariableText):\r
32         def __init__(self):\r
33                 Renderer.__init__(self)\r
34                 VariableText.__init__(self)\r
35                 if "8000" in HardwareInfo().get_device_name() or "500" in HardwareInfo().get_device_name() or "800se" in HardwareInfo().get_device_name():\r
36                         self.ZeigeTemp = True\r
37                 else:\r
38                         self.ZeigeTemp = False\r
39         GUI_WIDGET = eLabel\r
40 \r
41         def changed(self, what):\r
42                 if not self.suspended:\r
43                         if self.ZeigeTemp:\r
44                                 maxtemp = 0\r
45                                 try:\r
46                                         templist = sensors.getSensorsList(sensors.TYPE_TEMPERATURE)\r
47                                         tempcount = len(templist)\r
48                                         for count in range(tempcount):\r
49                                                 id = templist[count]\r
50                                                 tt = sensors.getSensorValue(id)\r
51                                                 if tt > maxtemp:\r
52                                                         maxtemp = tt\r
53                                 except:\r
54                                         pass\r
55                                 self.text = str(maxtemp) + "C"\r
56                         else:\r
57                                 loada = 0\r
58                                 try:\r
59                                         out_line = popen("cat /proc/loadavg").readline()\r
60                                         loada = out_line[:4]    \r
61                                 except:\r
62                                         pass\r
63                                 self.text = loada\r
64 \r
65         def onShow(self):\r
66                 self.suspended = False\r
67                 self.changed(None)\r
68 \r
69         def onHide(self):\r
70                 self.suspended = True\r