mirror of https://github.com/aristocratos/bpytop
Make proc filter code more concise
parent
6e608d965d
commit
8478d8eb51
25
bpytop.py
25
bpytop.py
|
@ -3425,11 +3425,9 @@ class ProcCollector(Collector):
|
||||||
if search:
|
if search:
|
||||||
if cls.detailed and p.info["pid"] == cls.detailed_pid:
|
if cls.detailed and p.info["pid"] == cls.detailed_pid:
|
||||||
cls.det_cpu = p.info["cpu_percent"]
|
cls.det_cpu = p.info["cpu_percent"]
|
||||||
if cls.case_sensitive:
|
for value in [ p.info["name"], " ".join(p.info["cmdline"]), str(p.info["pid"]), p.info["username"] ]:
|
||||||
process_info = [ p.info["name"], " ".join(p.info["cmdline"]), str(p.info["pid"]), p.info["username"] ]
|
if not cls.case_sensitive:
|
||||||
else:
|
value = value.lower()
|
||||||
process_info = [ p.info["name"].lower(), " ".join(p.info["cmdline"]).lower(), str(p.info["pid"]), p.info["username"].lower() ]
|
|
||||||
for value in process_info:
|
|
||||||
for s in search:
|
for s in search:
|
||||||
if s in value:
|
if s in value:
|
||||||
break
|
break
|
||||||
|
@ -3585,11 +3583,9 @@ class ProcCollector(Collector):
|
||||||
det_cpu = getinfo["cpu_percent"]
|
det_cpu = getinfo["cpu_percent"]
|
||||||
if "username" in getinfo and isinstance(getinfo["username"], float): getinfo["username"] = ""
|
if "username" in getinfo and isinstance(getinfo["username"], float): getinfo["username"] = ""
|
||||||
if "cmdline" in getinfo and isinstance(getinfo["cmdline"], float): getinfo["cmdline"] = ""
|
if "cmdline" in getinfo and isinstance(getinfo["cmdline"], float): getinfo["cmdline"] = ""
|
||||||
if cls.case_sensitive:
|
for value in [ name, str(pid), getinfo.get("username", ""), " ".join(getinfo.get("cmdline", "")) ]:
|
||||||
process_info = [ name, str(pid), getinfo.get("username", ""), " ".join(getinfo.get("cmdline", "")) ]
|
if not cls.case_sensitive:
|
||||||
else:
|
value = value.lower()
|
||||||
process_info = [ name.lower(), str(pid), getinfo.get("username", "").lower(), " ".join(getinfo.get("cmdline", "")).lower() ]
|
|
||||||
for value in process_info:
|
|
||||||
for s in search:
|
for s in search:
|
||||||
if s in value:
|
if s in value:
|
||||||
found = True
|
found = True
|
||||||
|
@ -4991,14 +4987,9 @@ def process_keys():
|
||||||
elif key == "c":
|
elif key == "c":
|
||||||
CONFIG.proc_per_core = not CONFIG.proc_per_core
|
CONFIG.proc_per_core = not CONFIG.proc_per_core
|
||||||
Collector.collect(ProcCollector, interrupt=True, redraw=True)
|
Collector.collect(ProcCollector, interrupt=True, redraw=True)
|
||||||
elif key == "f":
|
elif key in ["f", "F"]:
|
||||||
ProcBox.filtering = True
|
ProcBox.filtering = True
|
||||||
ProcCollector.case_sensitive = False
|
ProcCollector.case_sensitive = key == "F"
|
||||||
if not ProcCollector.search_filter: ProcBox.start = 0
|
|
||||||
Collector.collect(ProcCollector, redraw=True, only_draw=True)
|
|
||||||
elif key == "F":
|
|
||||||
ProcBox.filtering = True
|
|
||||||
ProcCollector.case_sensitive = True
|
|
||||||
if not ProcCollector.search_filter: ProcBox.start = 0
|
if not ProcCollector.search_filter: ProcBox.start = 0
|
||||||
Collector.collect(ProcCollector, redraw=True, only_draw=True)
|
Collector.collect(ProcCollector, redraw=True, only_draw=True)
|
||||||
elif key.lower() in ["t", "k", "i"] and (ProcBox.selected > 0 or ProcCollector.detailed):
|
elif key.lower() in ["t", "k", "i"] and (ProcBox.selected > 0 or ProcCollector.detailed):
|
||||||
|
|
Loading…
Reference in New Issue