Skip to content

Commit

Permalink
#1245 / linux / temperatures: skip sensors if 'name' file does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Mar 13, 2018
1 parent e258a67 commit 006533d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
=====
Expand Down
5 changes: 3 additions & 2 deletions psutil/_pslinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 006533d

Please sign in to comment.