mirror of https://github.com/aristocratos/bpytop
Fixed crash when filtering and showing info box, added improved cpu temperature detection.
parent
28bb245ade
commit
7a3654b731
35
bpytop.py
35
bpytop.py
|
@ -2443,16 +2443,22 @@ class CpuCollector(Collector):
|
||||||
try:
|
try:
|
||||||
for name, entries in psutil.sensors_temperatures().items():
|
for name, entries in psutil.sensors_temperatures().items():
|
||||||
for entry in entries:
|
for entry in entries:
|
||||||
if entry.label.startswith(("Package", "Tdie")):
|
if entry.label.startswith(("Package", "Tdie")) and hasattr(entry, "current"):
|
||||||
cpu_type = "intel" if entry.label.startswith("Package") else "ryzen"
|
cpu_type = "intel" if entry.label.startswith("Package") else "ryzen"
|
||||||
if not cls.cpu_temp_high:
|
if not cls.cpu_temp_high:
|
||||||
cls.cpu_temp_high, cls.cpu_temp_crit = round(entry.high), round(entry.critical)
|
if hasattr(entry, "high") and entry.high: cls.cpu_temp_high = round(entry.high)
|
||||||
|
else: cls.cpu_temp_high = 80
|
||||||
|
if hasattr(entry, "critical") and entry.critical: cls.cpu_temp_crit = round(entry.critical)
|
||||||
|
else: cls.cpu_temp_crit = 95
|
||||||
temp = round(entry.current)
|
temp = round(entry.current)
|
||||||
elif entry.label.startswith(("Core", "Tccd", "CPU")) or (name.lower() == "cpu" and not entry.label):
|
elif (entry.label.startswith(("Core", "Tccd", "CPU")) or (name.lower() == "cpu" and not entry.label)) and hasattr(entry, "current"):
|
||||||
if not cpu_type:
|
if not cpu_type:
|
||||||
cpu_type = "other"
|
cpu_type = "other"
|
||||||
if not cls.cpu_temp_high:
|
if not cls.cpu_temp_high:
|
||||||
cls.cpu_temp_high, cls.cpu_temp_crit = round(entry.high), round(entry.critical)
|
if hasattr(entry, "high") and entry.high: cls.cpu_temp_high = round(entry.high)
|
||||||
|
else: cls.cpu_temp_high = 80
|
||||||
|
if hasattr(entry, "critical") and entry.critical: cls.cpu_temp_crit = round(entry.critical)
|
||||||
|
else: cls.cpu_temp_crit = 95
|
||||||
temp = round(entry.current)
|
temp = round(entry.current)
|
||||||
cores.append(round(entry.current))
|
cores.append(round(entry.current))
|
||||||
if len(cores) < THREADS:
|
if len(cores) < THREADS:
|
||||||
|
@ -2928,7 +2934,6 @@ class ProcCollector(Collector): #! add interrupt on _collect and _draw
|
||||||
if cls.detailed and not cls.details.get("killed", False):
|
if cls.detailed and not cls.details.get("killed", False):
|
||||||
try:
|
try:
|
||||||
c_pid = cls.detailed_pid
|
c_pid = cls.detailed_pid
|
||||||
if not c_pid in cls.processes: raise psutil.NoSuchProcess
|
|
||||||
det = psutil.Process(c_pid)
|
det = psutil.Process(c_pid)
|
||||||
except (psutil.NoSuchProcess, psutil.ZombieProcess):
|
except (psutil.NoSuchProcess, psutil.ZombieProcess):
|
||||||
cls.details["killed"] = True
|
cls.details["killed"] = True
|
||||||
|
@ -2941,17 +2946,22 @@ class ProcCollector(Collector): #! add interrupt on _collect and _draw
|
||||||
attrs.extend(["nice", "terminal"])
|
attrs.extend(["nice", "terminal"])
|
||||||
if not SYSTEM == "MacOS": attrs.extend(["io_counters"])
|
if not SYSTEM == "MacOS": attrs.extend(["io_counters"])
|
||||||
|
|
||||||
|
if not c_pid in cls.processes: attrs.extend(["pid", "name", "cmdline", "threads", "username", "memory_percent", "cpu_percent"])
|
||||||
|
|
||||||
cls.details = det.as_dict(attrs=attrs, ad_value="")
|
cls.details = det.as_dict(attrs=attrs, ad_value="")
|
||||||
if det.parent() != None: cls.details["parent_name"] = det.parent().name()
|
if det.parent() != None: cls.details["parent_name"] = det.parent().name()
|
||||||
else: cls.details["parent_name"] = ""
|
else: cls.details["parent_name"] = ""
|
||||||
|
|
||||||
cls.details["pid"] = c_pid
|
cls.details["pid"] = c_pid
|
||||||
cls.details["name"] = cls.processes[c_pid]["name"]
|
if c_pid in cls.processes:
|
||||||
cls.details["cmdline"] = cls.processes[c_pid]["cmd"]
|
cls.details["name"] = cls.processes[c_pid]["name"]
|
||||||
cls.details["threads"] = f'{cls.processes[c_pid]["threads"]}'
|
cls.details["cmdline"] = cls.processes[c_pid]["cmd"]
|
||||||
cls.details["username"] = cls.processes[c_pid]["username"]
|
cls.details["threads"] = f'{cls.processes[c_pid]["threads"]}'
|
||||||
cls.details["memory_percent"] = cls.processes[c_pid]["mem"]
|
cls.details["username"] = cls.processes[c_pid]["username"]
|
||||||
cls.details["cpu_percent"] = round(cls.processes[c_pid]["cpu"] * (1 if CONFIG.proc_per_core else THREADS))
|
cls.details["memory_percent"] = cls.processes[c_pid]["mem"]
|
||||||
|
cls.details["cpu_percent"] = round(cls.processes[c_pid]["cpu"] * (1 if CONFIG.proc_per_core else THREADS))
|
||||||
|
else:
|
||||||
|
cls.details["cmdline"] = " ".join(cls.details["cmdline"]) or "[" + cls.details["name"] + "]"
|
||||||
cls.details["killed"] = False
|
cls.details["killed"] = False
|
||||||
if SYSTEM == "MacOS":
|
if SYSTEM == "MacOS":
|
||||||
cls.details["cpu_num"] = -1
|
cls.details["cpu_num"] = -1
|
||||||
|
@ -3645,9 +3655,6 @@ class Menu:
|
||||||
else:
|
else:
|
||||||
CpuCollector.sensor_method = ""
|
CpuCollector.sensor_method = ""
|
||||||
CpuCollector.got_sensors = False
|
CpuCollector.got_sensors = False
|
||||||
elif selected == "mini_mode":
|
|
||||||
Box.mini_mode = not Box.mini_mode
|
|
||||||
Draw.clear(saved=True)
|
|
||||||
Term.refresh(force=True)
|
Term.refresh(force=True)
|
||||||
cls.resized = False
|
cls.resized = False
|
||||||
elif key in ["left", "right"] and selected == "color_theme" and len(Theme.themes) > 1:
|
elif key in ["left", "right"] and selected == "color_theme" and len(Theme.themes) > 1:
|
||||||
|
|
Loading…
Reference in New Issue