From 006533d55316b6a9eb8004bd1b30acc3257fd15c Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 13 Mar 2018 11:46:42 +0100 Subject: [PATCH] #1245 / linux / temperatures: skip sensors if 'name' file does not exist --- HISTORY.rst | 1 + psutil/_pslinux.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index c58c8506c..edf1078ec 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 b57adb34e..a3653f989 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)