chore: add boilerplate

This commit is contained in:
aclist 2026-05-07 07:00:01 +09:00
parent fbbf0d9e66
commit d3e82fc4b1
4 changed files with 26 additions and 15 deletions

View File

@ -99,7 +99,7 @@ def connect(addr: str, appid: int, name: str, mods: list[str]) -> None:
f"-mod={concat}",
]
proc = subprocess.Popen([*params])
# check proc.returncode
return proc.returncode
def find_user_id(path: Path) -> str | None:

View File

@ -7,7 +7,7 @@ from dzgui.util.strings import init
# TODO: simplify
def is_dayz_running(dialog: bool = False) -> None:
def is_dayz_running(dialog: bool = False) -> bool | None:
if dialog is False:
return is_running(DAYZ_BINARY)
if is_running(DAYZ_BINARY) is True:
@ -15,7 +15,7 @@ def is_dayz_running(dialog: bool = False) -> None:
sys.exit(1)
def is_steam_running(dialog: bool = False) -> None:
def is_steam_running(dialog: bool = False) -> bool | None:
# TODO: check proc name of flatpak steam
if dialog is False:
return is_running(STEAM_CMD)

View File

@ -9,6 +9,8 @@ from typing import TYPE_CHECKING
import dzgui.api.pefile as PeFile
import dzgui.api.servers as Servers
import dzgui.api.steam.connect as Connect
from dzgui.api.steam import enqueue_mod, get_remote_signatures, get_needs_update
from dzgui.api.mods import get_mod_dir_size, get_local_mod_ids, get_local_mod_path
@ -24,6 +26,7 @@ from dzgui.init.proc import is_dayz_running, is_steam_running
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
from dzgui.util.format import format_mib
from dzgui.util.strings import dialog, server_timeout, checkmark
from dzgui.util.symlink import rebuild_symlinks
from dzgui.views.dialogs.generic import ExceptionDialog
from dzgui.views.dialogs.servers import ServerDetailsDialog, ServerModDialog
@ -209,14 +212,22 @@ class ConnectionManager:
print(self.record.ip)
print(self.record.gameport)
print(self.appid)
addr = f"{self.record.ip}:{self.record.gameport}"
playername = "test"
proc = Connect(addr, self.appid, playername, self.remote_mod_ids)
# TODO: test returncode
# proc.returncode
# TODO: wait for DAYZ_BINARY to load
# TODO: add to history file and list store
# steam api, concat mods
@call_on_thread("Waiting for Steam to update mods")
def update_mods(self) -> None:
# NOTE: fast enqueue all mods in auto mode
for title, mod, stamp, size in self.missing_mods:
# TODO: check for cancel event
# TODO: boolean cancel button on threadman dialog sets event inside threadman
# TODO: check for early cancel event via sigint
enqueue_mod(mod, self.appid)
time.sleep(2)
@ -227,20 +238,21 @@ class ConnectionManager:
time.sleep(1)
while True:
# NOTE: mods will finish at the same time
# TODO: check for cancel event
# TODO: check for early cancel event
cur_size = get_mod_dir_size(mod_path)
if cur_size == size:
break
time.sleep(1)
# TODO: update tree checkmarks
func = StoredFunc(self.controller.update_status, "All mods updated.")
self.thread_man.set_cleanup_func(func)
# TODO: after downloading mods, create all symlinks (and clone)
# GLib.idle_add(self._mark_finished)
# TODO: get config path or just push steam path directly
rebuild_symlinks(self.controller.get_prefs().paths.config)
# TODO: update version file
# def _mark_finished(self) -> None:
# self.controller.update_status("All mods updated.", mark_finished=True)
# TODO: update tree checkmarks
func = StoredFunc(
self.controller.update_status, "All mods updated.", mark_finished=True
)
self.thread_man.set_cleanup_func(func)
def update_and_connect(self) -> None:
if len(self.missing_mods) > 0:

View File

@ -14,7 +14,6 @@ logger = logging.getLogger(APP_NAME)
def rebuild_symlinks(config: Path) -> None:
path = lookup(config, Preferences.DEFAULT)
steam_path = Path(path)
dayz_path = PeFile.get_nested_app_path(steam_path, APPID_DAYZ)
# NOTE: unlink stale symlinks
for file in dayz_path.iterdir():
@ -33,7 +32,7 @@ def rebuild_symlinks(config: Path) -> None:
def clone_symlinks(steam_path: Path) -> None:
"""
Used after any symlink operation
Shares symlinks between builds. Used after any symlink operation
"""
try:
dayz_path = PeFile.get_nested_app_path(steam_path, APPID_DAYZ)