Merge pull request #234 from MendelGusmao/master

Better response handling
pull/235/head
Nicolas Hennion 2013-03-28 07:27:43 -07:00
commit e988d100c6
1 changed files with 12 additions and 5 deletions

View File

@ -726,7 +726,7 @@ class glancesGrabHDDTemp:
if self.initok:
data = ""
# Taking care of a possible subtle death of hddtemp
# Taking care of sudden deaths/stops of hddtemp daemon
try:
sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sck.connect((self.address, self.port))
@ -746,11 +746,18 @@ class glancesGrabHDDTemp:
else:
data = self.cache
self.cache = data
for line in data.split("\n"):
fields = data.split("|")
devices = (len(fields) - 1) / 5
for i in range(0, devices):
offset = i * 5
hddtemp_current = {}
fields = line.split('|')
hddtemp_current['label'] = fields[1].split("/")[-1]
hddtemp_current['value'] = int(fields[3])
temperature = fields[offset + 3]
if temperature == "ERR":
hddtemp_current['label'] = "hddtemp error"
hddtemp_current['value'] = 0
else:
hddtemp_current['label'] = fields[offset + 1].split("/")[-1]
hddtemp_current['value'] = int(temperature)
self.hddtemp_list.append(hddtemp_current)
def get(self):