summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2018-03-13 11:46:42 +0100
committerGiampaolo Rodola <g.rodola@gmail.com>2018-03-13 11:46:42 +0100
commit006533d55316b6a9eb8004bd1b30acc3257fd15c (patch)
tree32b59d5537e923b849e33051ece5569a566f0415
parente258a673940c39675d79a29ed495abc29b98035d (diff)
downloadpsutil-006533d55316b6a9eb8004bd1b30acc3257fd15c.tar.gz
#1245 / linux / temperatures: skip sensors if 'name' file does not exist
-rw-r--r--HISTORY.rst1
-rw-r--r--psutil/_pslinux.py5
2 files changed, 4 insertions, 2 deletions
diff --git a/HISTORY.rst b/HISTORY.rst
index c58c8506..edf1078e 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -16,6 +16,7 @@ XXXX-XX-XX
- 1216_: fix compatibility with python 2.6 on Windows (patch by Dan Vinakovsky)
- 1240_: [Windows] cpu_times() float loses accuracy in a long running system.
(patch by stswandering)
+- 1245_: [Linux] sensors_temperatures() may fail with IOError "no such file".
5.4.3
=====
diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py
index b57adb34..a3653f98 100644
--- a/psutil/_pslinux.py
+++ b/psutil/_pslinux.py
@@ -1141,17 +1141,18 @@ def sensors_temperatures():
for base in basenames:
try:
current = float(cat(base + '_input')) / 1000.0
+ unit_name = cat(os.path.join(os.path.dirname(base), 'name'),
+ binary=False)
except (IOError, OSError) as err:
# A lot of things can go wrong here, so let's just skip the
# whole entry.
# https://github.com/giampaolo/psutil/issues/1009
# https://github.com/giampaolo/psutil/issues/1101
# https://github.com/giampaolo/psutil/issues/1129
+ # https://github.com/giampaolo/psutil/issues/1245
warnings.warn("ignoring %r" % err, RuntimeWarning)
continue
- unit_name = cat(os.path.join(os.path.dirname(base), 'name'),
- binary=False)
high = cat(base + '_max', fallback=None)
critical = cat(base + '_crit', fallback=None)
label = cat(base + '_label', fallback='', binary=False)