From 1dc6bfed10d606e9fe5dc93887af5e8fe3ac99a8 Mon Sep 17 00:00:00 2001 From: DodoGTA Date: Tue, 20 Oct 2020 19:41:41 +0300 Subject: [PATCH] Fix missing CPU temperature/model (in certain cases) This commit fixes a regression caused by commit f932ae1c91c29987185ec8af5774c647faf93fb1 --- bpytop.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bpytop.py b/bpytop.py index 62abc03..c64ac5c 100755 --- a/bpytop.py +++ b/bpytop.py @@ -2727,26 +2727,26 @@ class CpuCollector(Collector): if temp == 1000 and name == s_name and (entry.label == s_label or str(num) == s_label) and round(entry.current) > 0: cpu_type = "other" if not cls.cpu_temp_high: - if hasattr(entry, "high") and entry.high > 1: cls.cpu_temp_high = round(entry.high) + if getattr(entry, "high", None) != None and entry.high > 1: cls.cpu_temp_high = round(entry.high) else: cls.cpu_temp_high = 80 - if hasattr(entry, "critical") and entry.critical > 1: cls.cpu_temp_crit = round(entry.critical) + if getattr(entry, "critical", None) != None and entry.critical > 1: cls.cpu_temp_crit = round(entry.critical) else: cls.cpu_temp_crit = 95 temp = round(entry.current) elif temp == 1000 and entry.label.startswith(("Package", "Tdie")) and hasattr(entry, "current") and round(entry.current) > 0: cpu_type = "intel" if entry.label.startswith("Package") else "ryzen" if not cls.cpu_temp_high: - if hasattr(entry, "high") and entry.high > 1: cls.cpu_temp_high = round(entry.high) + if getattr(entry, "high", None) != None and entry.high > 1: cls.cpu_temp_high = round(entry.high) else: cls.cpu_temp_high = 80 - if hasattr(entry, "critical") and entry.critical > 1: cls.cpu_temp_crit = round(entry.critical) + if getattr(entry, "critical", None) != None and entry.critical > 1: cls.cpu_temp_crit = round(entry.critical) else: cls.cpu_temp_crit = 95 temp = round(entry.current) elif (entry.label.startswith(("Core", "Tccd", "CPU")) or (name.lower().startswith("cpu") and not entry.label)) and hasattr(entry, "current") and round(entry.current) > 0: if not cpu_type: cpu_type = "other" if not cls.cpu_temp_high: - if hasattr(entry, "high") and entry.high > 1: cls.cpu_temp_high = round(entry.high) + if getattr(entry, "high", None) != None and entry.high > 1: cls.cpu_temp_high = round(entry.high) else: cls.cpu_temp_high = 60 if name == "cpu_thermal" else 80 - if hasattr(entry, "critical") and entry.critical > 1: cls.cpu_temp_crit = round(entry.critical) + if getattr(entry, "critical", None) != None and entry.critical > 1: cls.cpu_temp_crit = round(entry.critical) else: cls.cpu_temp_crit = 80 if name == "cpu_thermal" else 95 temp = round(entry.current) cores.append(round(entry.current))