diff options
| author | Giampaolo Rodola <g.rodola@gmail.com> | 2017-01-24 17:40:51 +0100 |
|---|---|---|
| committer | Giampaolo Rodola <g.rodola@gmail.com> | 2017-01-24 17:40:51 +0100 |
| commit | b64b87943b2e1d5955db90a94de611bf2c4bad2a (patch) | |
| tree | bddeb9517d98e34e9b9d1707002b194a2a130186 /psutil/_pslinux.py | |
| parent | 1818df036f4ab4b851e8cc0dd15f0bf28d8640f8 (diff) | |
| download | psutil-b64b87943b2e1d5955db90a94de611bf2c4bad2a.tar.gz | |
#371: temperatures: change returned data type from list to dict
Diffstat (limited to 'psutil/_pslinux.py')
| -rw-r--r-- | psutil/_pslinux.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py index 28e4a77c..bb3d171b 100644 --- a/psutil/_pslinux.py +++ b/psutil/_pslinux.py @@ -7,6 +7,7 @@ from __future__ import division import base64 +import collections import errno import functools import glob @@ -1096,7 +1097,8 @@ def boot_time(): if os.path.exists('/sys/class/hwmon'): - def sensors_temps(): + + def sensors_temperatures(): """Return hardware (CPU and others) temperatures as a list of named tuples including name, label, current, max and critical temperatures. @@ -1121,22 +1123,23 @@ if os.path.exists('/sys/class/hwmon'): with f: return f.read().strip() - ret = [] + ret = collections.defaultdict(list) basenames = sorted(set( [x.split('_')[0] for x in glob.glob('/sys/class/hwmon/hwmon*/temp*_*')])) for base in basenames: name = cat(os.path.join(os.path.dirname(base), 'name')) label = cat(base + '_label', replace='') - current = int(cat(base + '_input')) / 1000.0 + current = float(cat(base + '_input')) / 1000.0 high = cat(base + '_max', replace=None) critical = cat(base + '_crit', replace=None) + if high is not None: - high = int(high) / 1000.0 + high = float(high) / 1000.0 if critical is not None: - critical = int(critical) / 1000.0 + critical = float(critical) / 1000.0 - ret.append((name, label, current, high, critical)) + ret[name].append((label, current, high, critical)) return ret |
