Skip to content

Commit

Permalink
#971 / sensors_temperatures(): try to be nice to CentOS which has a d…
Browse files Browse the repository at this point in the history
…ifferent tree structure
  • Loading branch information
giampaolo committed Feb 5, 2017
1 parent 8113ead commit 561f32a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions psutil/_pslinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -1093,10 +1093,13 @@ def sensors_temperatures():
difficult to parse
"""
ret = collections.defaultdict(list)
# Will return an empty dict if path does not exist.
basenames = sorted(set(
[x.split('_')[0] for x in
glob.glob('/sys/class/hwmon/hwmon*/temp*_*')]))
basenames = glob.glob('/sys/class/hwmon/hwmon*/temp*_*')
if not basenames:
# CentOS has an intermediate /device directory:
# https://github.com/giampaolo/psutil/issues/971
basenames = glob.glob('/sys/class/hwmon/hwmon*/device/temp*_*')

basenames = sorted(set([x.split('_')[0] for x in basenames]))
for base in basenames:
unit_name = cat(os.path.join(os.path.dirname(base), 'name'),
binary=False)
Expand Down

0 comments on commit 561f32a

Please sign in to comment.