mirror of
https://github.com/aclist/dztui.git
synced 2026-10-30 22:52:42 +01:00
chore: add boilerplate
This commit is contained in:
1 parent
fbbf0d9e66
commit
d3e82fc4b1
4 files changed
+26
-15
No files matched your search
+1
-1
@@ -99,7 +99,7 @@ def connect(addr: str, appid: int, name: str, mods: list[str]) -> None:
|
|||||||
f"-mod={concat}",
|
f"-mod={concat}",
|
||||||
]
|
]
|
||||||
proc = subprocess.Popen([*params])
|
proc = subprocess.Popen([*params])
|
||||||
# check proc.returncode
|
return proc.returncode
|
||||||
|
|
||||||
|
|
||||||
def find_user_id(path: Path) -> str | None:
|
def find_user_id(path: Path) -> str | None:
|
||||||
|
|||||||
+2
-2
@@ -7,7 +7,7 @@ from dzgui.util.strings import init
|
|||||||
|
|
||||||
|
|
||||||
# TODO: simplify
|
# TODO: simplify
|
||||||
def is_dayz_running(dialog: bool = False) -> None:
|
def is_dayz_running(dialog: bool = False) -> bool | None:
|
||||||
if dialog is False:
|
if dialog is False:
|
||||||
return is_running(DAYZ_BINARY)
|
return is_running(DAYZ_BINARY)
|
||||||
if is_running(DAYZ_BINARY) is True:
|
if is_running(DAYZ_BINARY) is True:
|
||||||
@@ -15,7 +15,7 @@ def is_dayz_running(dialog: bool = False) -> None:
|
|||||||
sys.exit(1)
|
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
|
# TODO: check proc name of flatpak steam
|
||||||
if dialog is False:
|
if dialog is False:
|
||||||
return is_running(STEAM_CMD)
|
return is_running(STEAM_CMD)
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ from typing import TYPE_CHECKING
|
|||||||
|
|
||||||
import dzgui.api.pefile as PeFile
|
import dzgui.api.pefile as PeFile
|
||||||
import dzgui.api.servers as Servers
|
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.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
|
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.managers.threading import call_on_thread, StoredFunc, ThreadingManager
|
||||||
from dzgui.util.format import format_mib
|
from dzgui.util.format import format_mib
|
||||||
from dzgui.util.strings import dialog, server_timeout, checkmark
|
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.generic import ExceptionDialog
|
||||||
from dzgui.views.dialogs.servers import ServerDetailsDialog, ServerModDialog
|
from dzgui.views.dialogs.servers import ServerDetailsDialog, ServerModDialog
|
||||||
|
|
||||||
@@ -209,14 +212,22 @@ class ConnectionManager:
|
|||||||
print(self.record.ip)
|
print(self.record.ip)
|
||||||
print(self.record.gameport)
|
print(self.record.gameport)
|
||||||
print(self.appid)
|
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
|
# TODO: add to history file and list store
|
||||||
# steam api, concat mods
|
|
||||||
|
|
||||||
@call_on_thread("Waiting for Steam to update mods")
|
@call_on_thread("Waiting for Steam to update mods")
|
||||||
def update_mods(self) -> None:
|
def update_mods(self) -> None:
|
||||||
# NOTE: fast enqueue all mods in auto mode
|
# NOTE: fast enqueue all mods in auto mode
|
||||||
for title, mod, stamp, size in self.missing_mods:
|
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)
|
enqueue_mod(mod, self.appid)
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
@@ -227,20 +238,21 @@ class ConnectionManager:
|
|||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
while True:
|
while True:
|
||||||
# NOTE: mods will finish at the same time
|
# 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)
|
cur_size = get_mod_dir_size(mod_path)
|
||||||
if cur_size == size:
|
if cur_size == size:
|
||||||
break
|
break
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
# TODO: update tree checkmarks
|
# TODO: get config path or just push steam path directly
|
||||||
func = StoredFunc(self.controller.update_status, "All mods updated.")
|
rebuild_symlinks(self.controller.get_prefs().paths.config)
|
||||||
self.thread_man.set_cleanup_func(func)
|
# TODO: update version file
|
||||||
# TODO: after downloading mods, create all symlinks (and clone)
|
|
||||||
# GLib.idle_add(self._mark_finished)
|
|
||||||
|
|
||||||
# def _mark_finished(self) -> None:
|
# TODO: update tree checkmarks
|
||||||
# self.controller.update_status("All mods updated.", mark_finished=True)
|
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:
|
def update_and_connect(self) -> None:
|
||||||
if len(self.missing_mods) > 0:
|
if len(self.missing_mods) > 0:
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ logger = logging.getLogger(APP_NAME)
|
|||||||
def rebuild_symlinks(config: Path) -> None:
|
def rebuild_symlinks(config: Path) -> None:
|
||||||
path = lookup(config, Preferences.DEFAULT)
|
path = lookup(config, Preferences.DEFAULT)
|
||||||
steam_path = Path(path)
|
steam_path = Path(path)
|
||||||
|
|
||||||
dayz_path = PeFile.get_nested_app_path(steam_path, APPID_DAYZ)
|
dayz_path = PeFile.get_nested_app_path(steam_path, APPID_DAYZ)
|
||||||
# NOTE: unlink stale symlinks
|
# NOTE: unlink stale symlinks
|
||||||
for file in dayz_path.iterdir():
|
for file in dayz_path.iterdir():
|
||||||
@@ -33,7 +32,7 @@ def rebuild_symlinks(config: Path) -> None:
|
|||||||
|
|
||||||
def clone_symlinks(steam_path: Path) -> None:
|
def clone_symlinks(steam_path: Path) -> None:
|
||||||
"""
|
"""
|
||||||
Used after any symlink operation
|
Shares symlinks between builds. Used after any symlink operation
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
dayz_path = PeFile.get_nested_app_path(steam_path, APPID_DAYZ)
|
dayz_path = PeFile.get_nested_app_path(steam_path, APPID_DAYZ)
|
||||||
|
|||||||
Reference in new issue
Block a user