mirror of
https://github.com/aclist/dztui.git
synced 2026-10-30 14:42:54 +01:00
feat: wait for DayZ process
This commit is contained in:
1 parent
ff0ced1c33
commit
fb5397ae91
4 files changed
+27
-12
No files matched your search
+1
-1
@@ -102,7 +102,7 @@ def connect(addr: str, appid: int, name: str, mods: list[str]) -> None:
|
|||||||
f"-name={name}",
|
f"-name={name}",
|
||||||
f"-mod={concat}",
|
f"-mod={concat}",
|
||||||
]
|
]
|
||||||
proc = subprocess.Popen([*params])
|
proc = subprocess.run([*params])
|
||||||
return proc.returncode
|
return proc.returncode
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -479,3 +479,4 @@ class Controller(GObject.GObject):
|
|||||||
|
|
||||||
def get_steam_client_name(self) -> str:
|
def get_steam_client_name(self) -> str:
|
||||||
return self.mediator.options.get_client_name()
|
return self.mediator.options.get_client_name()
|
||||||
|
|
||||||
+8
-1
@@ -16,7 +16,14 @@ from dzgui.util.strings import init
|
|||||||
|
|
||||||
# TODO: move to util.proc
|
# TODO: move to util.proc
|
||||||
def is_dayz_running() -> bool:
|
def is_dayz_running() -> bool:
|
||||||
return is_running(DAYZ_BINARY)
|
procs = []
|
||||||
|
substring = DAYZ_BINARY
|
||||||
|
for proc in psutil.process_iter():
|
||||||
|
try:
|
||||||
|
procs.append(proc.cmdline())
|
||||||
|
except Exception as e:
|
||||||
|
continue
|
||||||
|
return any(substring in item for sublist in procs for item in sublist)
|
||||||
|
|
||||||
|
|
||||||
def is_steam_running(cmd: str) -> bool:
|
def is_steam_running(cmd: str) -> bool:
|
||||||
|
|||||||
@@ -32,9 +32,10 @@ from dzgui.const.constants import (
|
|||||||
APPNAME_DAYZ_EXP,
|
APPNAME_DAYZ_EXP,
|
||||||
DAYZ_BINARY,
|
DAYZ_BINARY,
|
||||||
)
|
)
|
||||||
from dzgui.const.enum import Preferences
|
from dzgui.const.enum import NotebookPage, Preferences
|
||||||
from dzgui.init.proc import foreground, is_dayz_running, is_steam_running, is_running
|
from dzgui.init.proc import foreground, is_dayz_running, is_steam_running, is_running
|
||||||
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
|
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
|
||||||
|
from dzgui.strings.dialogs import waiting_for_launch
|
||||||
from dzgui.strings.server_mods import checkmark, resync
|
from dzgui.strings.server_mods import checkmark, resync
|
||||||
from dzgui.util.format import format_mib
|
from dzgui.util.format import format_mib
|
||||||
from dzgui.util.strings import dialog, server_timeout
|
from dzgui.util.strings import dialog, server_timeout
|
||||||
@@ -246,16 +247,22 @@ class ConnectionManager:
|
|||||||
def _connect_steam(self) -> None:
|
def _connect_steam(self) -> None:
|
||||||
addr = f"{self.record.ip}:{self.record.gameport}"
|
addr = f"{self.record.ip}:{self.record.gameport}"
|
||||||
playername = self.controller.query_config(Preferences.NAME)
|
playername = self.controller.query_config(Preferences.NAME)
|
||||||
proc = connect(addr, self.appid, playername, self.remote_mod_ids)
|
rc = connect(addr, self.appid, playername, self.remote_mod_ids)
|
||||||
# TODO: test returncode
|
if rc != 0:
|
||||||
|
# TODO: log/pop the error
|
||||||
|
func = StoredFunc(self.controller.update_status)
|
||||||
|
self.thread_man.set_cleanup_func(func)
|
||||||
|
return
|
||||||
|
|
||||||
# self.thread_man.update_dialog("Waiting for DayZ to launch")
|
self.thread_man.update_dialog(waiting_for_launch)
|
||||||
# while not is_running(DAYZ_BINARY):
|
while True:
|
||||||
# time.sleep(1)
|
if is_dayz_running():
|
||||||
# TODO: wait for DAYZ_BINARY to load
|
break
|
||||||
# on cleanup:
|
time.sleep(1)
|
||||||
# TODO: add to history file and list store
|
# TODO: add to history file and list store
|
||||||
# proxy_model.append_to_history()
|
# proxy_model.append_to_history()
|
||||||
|
func = StoredFunc(self.controller.open_page, NotebookPage.SERVERS)
|
||||||
|
self.thread_man.set_cleanup_func(func)
|
||||||
|
|
||||||
def _update_mods(self, raise_window: bool) -> None:
|
def _update_mods(self, raise_window: bool) -> None:
|
||||||
# NOTE: fast enqueue all mods in auto mode
|
# NOTE: fast enqueue all mods in auto mode
|
||||||
@@ -294,7 +301,7 @@ class ConnectionManager:
|
|||||||
def update_and_connect(self, raise_window: bool) -> None:
|
def update_and_connect(self, raise_window: bool) -> None:
|
||||||
if len(self.missing_mods) > 0:
|
if len(self.missing_mods) > 0:
|
||||||
self._update_mods(raise_window)
|
self._update_mods(raise_window)
|
||||||
|
self._connect_steam()
|
||||||
else:
|
else:
|
||||||
self._connect_steam()
|
self._connect_steam()
|
||||||
func = StoredFunc(self.controller.update_status)
|
# TODO: use this only if going back before launching
|
||||||
self.thread_man.set_cleanup_func(func)
|
|
||||||
Reference in new issue
Block a user