fix: restore prior proc monitor logic (avoids conflicts)

This commit is contained in:
aclist committed 2026-07-12 10:14:55 +09:00
1 parent 2e41856348
commit e664f68624
1 file changed
+33 -17
+33 -17
View File
@@ -15,6 +15,7 @@ from dzgui.const.constants import (
APPID_DAYZ, APPID_DAYZ,
APPID_DAYZ_EXP, APPID_DAYZ_EXP,
APP_NAME, APP_NAME,
DAYZ_BINARY,
DEBIAN_STEAM_PATH, DEBIAN_STEAM_PATH,
DEFAULT_STEAM_PATH, DEFAULT_STEAM_PATH,
FLATPAK_STEAM_PATH, FLATPAK_STEAM_PATH,
@@ -219,6 +220,7 @@ def find_user_id(path: Path) -> str | None:
logger.warn(e) logger.warn(e)
return None return None
def find_user_id_32(path: Path) -> int: def find_user_id_32(path: Path) -> int:
uid = find_user_id(path) uid = find_user_id(path)
if uid is None: if uid is None:
@@ -301,21 +303,25 @@ def get_running_app() -> int | None:
PROC_NAME = "steam" PROC_NAME = "steam"
SUBPROC_NAME = "reaper" SUBPROC_NAME = "reaper"
FLAG = "AppId" FLAG = "AppId"
# NOTE: may cause conflicts if multiple apps are running
for proc in psutil.process_iter(): try:
if proc.name() == PROC_NAME: for proc in psutil.process_iter():
subprocs = proc.children() if proc.name() == PROC_NAME:
filtered = (proc for proc in subprocs if proc.name() == SUBPROC_NAME) subprocs = proc.children()
try: filtered = (proc for proc in subprocs if proc.name() == SUBPROC_NAME)
proc = next(filtered) try:
except StopIteration: proc = next(filtered)
return None except StopIteration:
args = proc.cmdline() return None
appid = (row for row in args if FLAG in row) args = proc.cmdline()
try: appid = (row for row in args if FLAG in row)
return int(next(appid).split("=")[1]) try:
except StopIteration: return int(next(appid).split("=")[1])
return None except StopIteration:
return None
except Exception as e:
logger.debug(e)
return None
return None return None
@@ -337,9 +343,11 @@ def get_app_allows_downloads(path: Path, appid: int) -> bool:
case _: case _:
return True return True
def get_config(path: Path) -> Path: def get_config(path: Path) -> Path:
return path.joinpath("config/config.vdf") return path.joinpath("config/config.vdf")
def get_client_allows_downloads(path: Path) -> bool: def get_client_allows_downloads(path: Path) -> bool:
config = get_config(path) config = get_config(path)
try: try:
@@ -360,8 +368,16 @@ def get_client_allows_downloads(path: Path) -> bool:
def is_dayz_running() -> bool: def is_dayz_running() -> bool:
appid = get_running_app() """Subprocesses spawned from Steam will not show up in regular process tree"""
return appid in (APPID_DAYZ, APPID_DAYZ_EXP) procs = []
substring = DAYZ_BINARY
for proc in psutil.process_iter():
try:
procs.append(proc.cmdline())
except Exception as e:
logger.warning(e)
continue
return any(substring in item for sublist in procs for item in sublist)
def get_app_path(folders_path: Path, appid: int) -> Path: def get_app_path(folders_path: Path, appid: int) -> Path: