Skip to content

Commit

Permalink
more detailed error msg in case of missing file when reading temperat…
Browse files Browse the repository at this point in the history
…ures
  • Loading branch information
giampaolo committed Mar 13, 2018
1 parent 006533d commit a160034
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions psutil/_pslinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -1140,17 +1140,19 @@ 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)
path = base + '_input'
current = float(cat(path)) / 1000.0
path = os.path.join(os.path.dirname(base), 'name')
unit_name = cat(path, 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)
warnings.warn("ignoring %r for file %r" % (err, path),
RuntimeWarning)
continue

high = cat(base + '_max', fallback=None)
Expand Down

0 comments on commit a160034

Please sign in to comment.