* fixed temperature for AMD

* fixes #72

* wrapped into try...except block
This commit is contained in:
Vadym Stupakov 2020-08-06 13:35:12 +03:00 committed by GitHub
parent e7c7e39d62
commit b55c61574c
1 changed files with 11 additions and 4 deletions

View File

@ -477,10 +477,17 @@ def sysinfo():
print("\nTemperature for each physical core:\n") print("\nTemperature for each physical core:\n")
core_num = 0 core_num = 0
while core_num < core_temp_num: while core_num < core_temp_num:
temp = float("nan")
try:
if "coretemp" in core_temp: if "coretemp" in core_temp:
temp = core_temp['coretemp'][core_num].current temp = core_temp['coretemp'][core_num].current
else: elif "k10temp" in core_temp:
# https://www.kernel.org/doc/Documentation/hwmon/k10temp
temp = core_temp['k10temp'].current
elif "acpitz" in core_temp:
temp = core_temp['acpitz'][0].current temp = core_temp['acpitz'][0].current
except:
pass
print(f"CPU{core_num} temp: {temp:.0f}°C") print(f"CPU{core_num} temp: {temp:.0f}°C")
core_num += 1 core_num += 1