Change proc filter to be case-insensitive

pull/234/head
Umar Javed 2021-01-05 15:08:03 +05:00
parent b443a9a576
commit 337e7e2dbb
1 changed files with 8 additions and 8 deletions

View File

@ -3393,7 +3393,7 @@ class ProcCollector(Collector):
sorting: str = CONFIG.proc_sorting sorting: str = CONFIG.proc_sorting
reverse: bool = not CONFIG.proc_reversed reverse: bool = not CONFIG.proc_reversed
proc_per_cpu: bool = CONFIG.proc_per_core proc_per_cpu: bool = CONFIG.proc_per_core
search: str = cls.search_filter search: List[str] = [i.strip() for i in cls.search_filter.lower().split(",")] if cls.search_filter else []
err: float = 0.0 err: float = 0.0
n: int = 0 n: int = 0
@ -3419,9 +3419,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"]
for value in [ p.info["name"], " ".join(p.info["cmdline"]), str(p.info["pid"]), p.info["username"] ]: for value in [ p.info["name"].lower(), " ".join(p.info["cmdline"]).lower(), str(p.info["pid"]), p.info["username"].lower() ]:
for s in search.split(","): for s in search:
if s.strip() in value: if s in value:
break break
else: continue else: continue
break break
@ -3533,7 +3533,7 @@ class ProcCollector(Collector):
if len(cls.details_mem) > ProcBox.width: del cls.details_mem[0] if len(cls.details_mem) > ProcBox.width: del cls.details_mem[0]
@classmethod @classmethod
def _tree(cls, sort_cmd, reverse: bool, proc_per_cpu: bool, search: str): def _tree(cls, sort_cmd, reverse: bool, proc_per_cpu: bool, search: List[str]):
'''List all processess in a tree view with pid, name, threads, username, memory percent and cpu percent''' '''List all processess in a tree view with pid, name, threads, username, memory percent and cpu percent'''
out: Dict = {} out: Dict = {}
err: float = 0.0 err: float = 0.0
@ -3575,9 +3575,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"] = ""
for value in [ name, str(pid), getinfo.get("username", ""), " ".join(getinfo.get("cmdline", "")) ]: for value in [ name.lower(), str(pid), getinfo.get("username", "").lower(), " ".join(getinfo.get("cmdline", "")).lower() ]:
for s in search.split(","): for s in search:
if s.strip() in value: if s in value:
found = True found = True
break break
else: continue else: continue