-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathutils.py
28 lines (20 loc) · 1009 Bytes
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from typing import Dict, Generator, List
from psutil import STATUS_ZOMBIE, Process, process_iter
def parse_cmdline_args(cmdline_args) -> Dict[str, str]:
cmdline_args_parsed = {}
for cmdline_arg in cmdline_args:
if len(cmdline_arg) > 0 and "=" in cmdline_arg:
key, value = cmdline_arg[2:].split("=", 1)
cmdline_args_parsed[key] = value
return cmdline_args_parsed
def _return_ux_process() -> Generator[Process, None, None]:
for process in process_iter(attrs=["cmdline"]):
if process.status() == STATUS_ZOMBIE:
continue
cmdline: List[str] = process.info.get("cmdline", [])
if process.name() in ["LeagueClientUx.exe", "LeagueClientUx"]:
yield process
# Check cmdline for the executable, especially useful in Linux environments
# where process names might differ due to compatibility layers like wine.
if cmdline and cmdline[0].endswith("LeagueClientUx.exe"):
yield process