1
# -*- coding: UTF-8 -*-
3
# +-------------------------------------------------------------------------------------+
5
# +-------------------------------------------------------------------------------------+
6
# | Copyright (c) 2005,2006 Adolfo González Blázquez <code@infinicode.org> |
8
# | This program is free software; you can redistribute it and/or |
9
# | modify it under the terms of the GNU General Public License |
10
# | as published by the Free Software Foundation; either version 2 |
11
# | of the License, or (at your option) any later version. |
13
# | This program is distributed in the hope that it will be useful, |
14
# | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
# | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
# | GNU General Public License for more details. |
18
# | You should have received a copy of the GNU General Public License |
19
# | along with this program; if not, write to the Free Software |
20
# | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
21
# +-------------------------------------------------------------------------------------+
23
from telnetlib import Telnet
29
self.host = 'localhost'
34
# Read data from hddtemp telnet interface
38
tn = Telnet(self.host, self.port)
41
data = data.split('||')
42
for i in data: self.hds.append(i.lstrip('|').rstrip('|').split('|'))
46
# Get the name of the hardware sensor
47
def get_sensor_name(self): return 'HDDTEMP'
49
# Is there acpi thermal_zone support on machine?
50
def temp_support(self):
51
if self.hds != None: return True
55
# Return a list with the thermal zones availables
57
if self.temp_support():
58
return range(len(self.hds))
61
# Return zone name at position num
62
def get_zone_name(self, num):
63
if self.temp_support():
68
# Return zone name to display at position num
69
def get_zone_display_name(self, num):
70
return self.hds[num][1] + ' (' + self.hds[num][0] + ')'
73
# Reads temperature from zone
74
def get_zone_temp(self, zone):
75
if self.temp_support():
77
return self.hds[int(zone)][2]