-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Osx temps #1284
Osx temps #1284
Changes from 5 commits
2310e46
9952285
b083462
0dd82f9
10b9a26
1483757
ea8a5da
8ec6063
9d8cef0
f19feab
75af526
44493d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
|
||
import contextlib | ||
import errno | ||
import collections | ||
import functools | ||
import os | ||
from socket import AF_INET | ||
|
@@ -212,6 +213,42 @@ def disk_partitions(all=False): | |
# ===================================================================== | ||
|
||
|
||
def sensors_temperatures(): | ||
"""Return CPU temperatures | ||
including key name and temperature. | ||
""" | ||
ret = collections.defaultdict(list) | ||
|
||
# This handles returning per-core temperature. The SMCkeys for core | ||
# temperatue are known | ||
rawlist = cext.cpu_cores_temperatures() | ||
for core in rawlist: | ||
ret["CPU"].append((core[0], core[1], None, None)) | ||
|
||
# Additional CPU sensors | ||
rawlist = cext.cpu_misc_temperatures() | ||
for core in rawlist: | ||
ret["CPU"].append((core[0], core[1], None, None)) | ||
|
||
try: | ||
rawlist = cext.battery_temperatures() | ||
if rawlist is not None: | ||
for batt in rawlist: | ||
ret["Batteries"].append((batt[0], batt[1], None, None)) | ||
except(SystemError): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? In general you want to let the underlying C extension raise exceptions (e.g. |
||
pass | ||
|
||
try: | ||
rawlist = cext.hdd_temperatures() | ||
if rawlist is not None: | ||
for temp in rawlist: | ||
ret["HDD"].append((temp[0], temp[1], None, None)) | ||
except(SystemError): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
pass | ||
|
||
return dict(ret) | ||
|
||
|
||
def sensors_battery(): | ||
"""Return battery information. | ||
""" | ||
|
@@ -230,6 +267,19 @@ def sensors_battery(): | |
return _common.sbattery(percent, secsleft, power_plugged) | ||
|
||
|
||
def sensors_fans(): | ||
"""Return fans speed information. | ||
""" | ||
ret = collections.defaultdict(list) | ||
try: | ||
for key, value in cext.sensors_fans().items(): | ||
ret["Fans"].append(_common.sfan(key, int(value))) | ||
except (SystemError): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
# Returns an empty dict if no fans were detected | ||
pass | ||
return dict(ret) | ||
|
||
|
||
# ===================================================================== | ||
# --- network | ||
# ===================================================================== | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please put the whole docstring on 1 line