summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Hennion <nicolashennion@gmail.com>2013-03-28 07:27:43 -0700
committerNicolas Hennion <nicolashennion@gmail.com>2013-03-28 07:27:43 -0700
commite988d100c6f5e05d83b1b9755728a1da31aba061 (patch)
tree0fbcf63da718cbbd1e40645ba4c4115967068182
parent7f6953b3251d99e488f219943d2deec7dce39a9c (diff)
parent35fe3e8d2a276331a798795e1eaa41128d7c398e (diff)
Merge pull request #234 from MendelGusmao/master
Better response handling
-rwxr-xr-xglances/glances.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/glances/glances.py b/glances/glances.py
index a78278bf..47ddb196 100755
--- a/glances/glances.py
+++ b/glances/glances.py
@@ -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):