mirror of
https://github.com/aclist/dztui.git
synced 2026-11-07 10:30:40 +01:00
Compare commits
34
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c56f16633 | ||
|
|
2b87272b52 | ||
|
|
4de5147899 | ||
|
|
4c31cd7ecd | ||
|
|
61f90d6016 | ||
|
|
cd1fd1b179 | ||
|
|
1b25c8fadb | ||
|
|
18146bf66f | ||
|
|
8ae54d436a | ||
|
|
4d94551f87 | ||
|
|
1154789f8b | ||
|
|
cbccd4c5f6 | ||
|
|
8cac752a0d | ||
|
|
580273053c | ||
|
|
8d75c1f7b2 | ||
|
|
320c2f692e | ||
|
|
413d84b2b5 | ||
|
|
c751b277d0 | ||
|
|
7f36a3acad | ||
|
|
5780d3daff | ||
|
|
e692e1d139 | ||
|
|
38d44a7952 | ||
|
|
611e3e6e58 | ||
|
|
d5b415316e | ||
|
|
0eeec490c2 | ||
|
|
782157006a | ||
|
|
3be7bc0e02 | ||
|
|
9e7102aaba | ||
|
|
6516e7ae3c | ||
|
|
46c1da232e | ||
|
|
5280121e43 | ||
|
|
17c63cf85f | ||
|
|
488d98800f | ||
|
|
4eac5055cb |
No files matched your search
@@ -26,7 +26,7 @@ You can install it via the following set of commands:
|
|||||||
.. code:: console
|
.. code:: console
|
||||||
|
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install libgirepository-2.0
|
sudo apt install libgirepository-2.0-0
|
||||||
|
|
||||||
Next steps
|
Next steps
|
||||||
---------------
|
---------------
|
||||||
|
|||||||
@@ -289,13 +289,14 @@ def query_direct(ip: str, qport: int, timeout: float = 3.0) -> dict[str, Any] |
|
|||||||
|
|
||||||
|
|
||||||
def get_details(record: Record) -> Details:
|
def get_details(record: Record) -> Details:
|
||||||
|
# TODO: consolidate try/except statements
|
||||||
ip = record.ip
|
ip = record.ip
|
||||||
qport = record.qport
|
qport = record.qport
|
||||||
default_str = strings.none_provided
|
default_str = strings.none_provided
|
||||||
|
|
||||||
try:
|
try:
|
||||||
info = a2s.info((ip, qport))
|
info = a2s.info((ip, qport))
|
||||||
except TimeoutError:
|
except (TimeoutError, a2s.exceptions.BrokenMessageError):
|
||||||
return Details(None, default_str, False)
|
return Details(None, default_str, False)
|
||||||
try:
|
try:
|
||||||
rules = dayzquery.dayz_rules((ip, qport))
|
rules = dayzquery.dayz_rules((ip, qport))
|
||||||
|
|||||||
@@ -0,0 +1,152 @@
|
|||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
|
||||||
|
from dzgui.const.constants import APP_NAME, APP_NAME_LOWER
|
||||||
|
from dzgui.const.enum import Preferences
|
||||||
|
from dzgui.config.query import lookup
|
||||||
|
from dzgui.config.userprefs import UserPrefs
|
||||||
|
from dzgui.config.xdg import get_xdg_paths, parse_filepaths
|
||||||
|
from dzgui.init.migrate import (
|
||||||
|
has_new_config,
|
||||||
|
copy_state_files,
|
||||||
|
migrate_cols_file,
|
||||||
|
)
|
||||||
|
from dzgui.init.flock import lock_acquire
|
||||||
|
from dzgui.init.prereqs import has_steam_client
|
||||||
|
from dzgui.strings import boot
|
||||||
|
|
||||||
|
# from dzgui.util.map_count import get_map_count
|
||||||
|
from dzgui.util.deck import is_steam_deck, is_game_mode
|
||||||
|
from dzgui.util.localize import set_locale
|
||||||
|
from dzgui.util.strings import init
|
||||||
|
|
||||||
|
from dzgui.views.base import App
|
||||||
|
from dzgui.views.dialogs.boot import BootWindow
|
||||||
|
from dzgui.views.dialogs.early_alert import EarlyAlertDialog
|
||||||
|
from dzgui.views.dialogs.wizard import SetupWizard
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
logger = logging.getLogger(APP_NAME)
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: profile load time
|
||||||
|
def make_parents(path: "Path") -> None:
|
||||||
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
|
||||||
|
def setup_logger(log_path: "Path") -> None:
|
||||||
|
_format = (
|
||||||
|
"%(asctime)s␞%(levelname)s␞%(filename)s::%(funcName)s::%(lineno)s␞%(message)s"
|
||||||
|
)
|
||||||
|
fh = logging.FileHandler(log_path)
|
||||||
|
formatter = logging.Formatter(_format)
|
||||||
|
fh.setFormatter(formatter)
|
||||||
|
fh.setLevel(logging.DEBUG)
|
||||||
|
logger.setLevel(logging.DEBUG)
|
||||||
|
logger.addHandler(fh)
|
||||||
|
|
||||||
|
|
||||||
|
def copy_bare_configs(config: "Path", resolution: "Path") -> tuple[bool, bool]:
|
||||||
|
# NOTE: temporary workaround for #375
|
||||||
|
conf = "config.json"
|
||||||
|
state = [
|
||||||
|
"dzg.history",
|
||||||
|
"dzg.versions",
|
||||||
|
"dzg.res.json",
|
||||||
|
"dzg.filters.json",
|
||||||
|
"dzg.columns.json",
|
||||||
|
"dzg.notes.json",
|
||||||
|
"ips.csv",
|
||||||
|
".month",
|
||||||
|
]
|
||||||
|
config_changed = False
|
||||||
|
state_changed = False
|
||||||
|
if config.parent.exists() is False:
|
||||||
|
new_file = config
|
||||||
|
old_file = config.parent.parent / conf
|
||||||
|
if old_file.is_file():
|
||||||
|
try:
|
||||||
|
make_parents(new_file)
|
||||||
|
shutil.copy(old_file, new_file)
|
||||||
|
config_changed = True
|
||||||
|
except Exception as e:
|
||||||
|
logger.critical(e)
|
||||||
|
if resolution.parent.exists() is False:
|
||||||
|
state_path = resolution.parent
|
||||||
|
for state_file in state:
|
||||||
|
old_file = state_path.parent / state_file
|
||||||
|
if old_file.is_file():
|
||||||
|
try:
|
||||||
|
new_file = state_path / state_file
|
||||||
|
make_parents(new_file)
|
||||||
|
shutil.copy(old_file, new_file)
|
||||||
|
state_changed = True
|
||||||
|
except Exception as e:
|
||||||
|
logger.critical(e)
|
||||||
|
return (config_changed, state_changed)
|
||||||
|
|
||||||
|
|
||||||
|
def load_gui(version: str, is_debug: bool) -> None:
|
||||||
|
lock = lock_acquire() # noqa
|
||||||
|
|
||||||
|
set_locale()
|
||||||
|
# NOTE: consider aborting this check if steam deck
|
||||||
|
xdg_paths = get_xdg_paths()
|
||||||
|
XDG = parse_filepaths(xdg_paths)
|
||||||
|
|
||||||
|
copy_bare_configs(XDG.config, XDG.resolution)
|
||||||
|
|
||||||
|
if XDG.resolution.parent.is_dir() is False:
|
||||||
|
make_parents(XDG.resolution)
|
||||||
|
|
||||||
|
if XDG.debug.is_file() is False:
|
||||||
|
make_parents(XDG.debug)
|
||||||
|
|
||||||
|
_is_steam_deck = is_steam_deck()
|
||||||
|
_is_game_mode = is_game_mode() if _is_steam_deck else False
|
||||||
|
if _is_game_mode:
|
||||||
|
# NOTE: this may no longer be necessary on newer versions of SteamOS
|
||||||
|
del os.environ["GTK_IM_MODULE"]
|
||||||
|
|
||||||
|
if has_new_config(XDG.config) is False:
|
||||||
|
migrate_cols_file(XDG.columns)
|
||||||
|
copy_state_files(xdg_paths["XDG_STATE_HOME"])
|
||||||
|
# TODO: add logging inside wizard
|
||||||
|
SetupWizard(_is_steam_deck, XDG.config)
|
||||||
|
|
||||||
|
# NOTE: implies that setup wizard failed or was closed
|
||||||
|
if has_new_config(XDG.config) is False:
|
||||||
|
return
|
||||||
|
|
||||||
|
setup_logger(XDG.debug)
|
||||||
|
with open(XDG.debug, "w") as f:
|
||||||
|
f.truncate(0)
|
||||||
|
|
||||||
|
if _is_steam_deck is False:
|
||||||
|
# TODO: sudo escalation dialog
|
||||||
|
# count = get_map_count()
|
||||||
|
# TODO: move into module
|
||||||
|
if has_steam_client() is False:
|
||||||
|
EarlyAlertDialog(init.requires_steam)
|
||||||
|
|
||||||
|
bootwin = BootWindow(XDG, version)
|
||||||
|
local_coords, latest_release = bootwin.get_results()
|
||||||
|
|
||||||
|
use_miles = lookup(XDG.config, Preferences.DIST)
|
||||||
|
prefs = UserPrefs(
|
||||||
|
is_steam_deck=_is_steam_deck,
|
||||||
|
is_game_mode=_is_game_mode,
|
||||||
|
is_debug=is_debug,
|
||||||
|
coords=local_coords,
|
||||||
|
version=version,
|
||||||
|
paths=XDG,
|
||||||
|
latest_release=latest_release,
|
||||||
|
use_miles=use_miles,
|
||||||
|
)
|
||||||
|
print(boot.all_ok)
|
||||||
|
App(prefs)
|
||||||
+6
-5
@@ -29,9 +29,9 @@ def is_writeable(path_str: str) -> bool:
|
|||||||
if not path.exists():
|
if not path.exists():
|
||||||
try:
|
try:
|
||||||
path.mkdir(parents=True)
|
path.mkdir(parents=True)
|
||||||
|
path.unlink()
|
||||||
except OSError:
|
except OSError:
|
||||||
return False
|
return False
|
||||||
path.unlink()
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -55,11 +55,12 @@ def get_xdg_paths() -> dict:
|
|||||||
|
|
||||||
resolved_paths = {}
|
resolved_paths = {}
|
||||||
for path in xdg_paths:
|
for path in xdg_paths:
|
||||||
rp = os.environ.get(path)
|
real_path = os.environ.get(path)
|
||||||
if rp is not None and is_writeable(rp):
|
if real_path is not None and is_writeable(real_path):
|
||||||
resolved_paths[path] = Path(rp)
|
new_path = Path(real_path)
|
||||||
else:
|
else:
|
||||||
resolved_paths[path] = xdg_paths[path] / APP_NAME_LOWER
|
new_path = xdg_paths[path]
|
||||||
|
resolved_paths[path] = new_path / APP_NAME_LOWER
|
||||||
return resolved_paths
|
return resolved_paths
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+4
-5
@@ -1,11 +1,12 @@
|
|||||||
import platform
|
import platform
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from pathlib import Path
|
from ctypes.util import find_library
|
||||||
from warnings import deprecated
|
from warnings import deprecated
|
||||||
|
|
||||||
LIB = "libgirepository-2.0"
|
LIB = "libgirepository-2.0"
|
||||||
|
|
||||||
|
|
||||||
@deprecated("currently unused")
|
@deprecated("currently unused")
|
||||||
def is_debian() -> bool:
|
def is_debian() -> bool:
|
||||||
"""
|
"""
|
||||||
@@ -39,12 +40,10 @@ def is_debian() -> bool:
|
|||||||
|
|
||||||
|
|
||||||
def has_libgi() -> bool:
|
def has_libgi() -> bool:
|
||||||
parent_dir = Path("/usr/lib64")
|
return bool(find_library("girepository-2.0"))
|
||||||
exists = any(LIB in subdir.name for subdir in parent_dir.iterdir())
|
|
||||||
return exists
|
|
||||||
|
|
||||||
|
|
||||||
def test_missing_lib() -> bool:
|
def test_libgi_missing() -> None:
|
||||||
msg = f"System is missing the required library '{LIB}'. Install it via your system package manager."
|
msg = f"System is missing the required library '{LIB}'. Install it via your system package manager."
|
||||||
if has_libgi() is False:
|
if has_libgi() is False:
|
||||||
print(msg)
|
print(msg)
|
||||||
|
|||||||
+6
-103
@@ -1,40 +1,11 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import logging
|
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
from dzgui.const.constants import APP_NAME
|
from dzgui.const.constants import APP_NAME
|
||||||
from dzgui.const.enum import Preferences
|
from dzgui.init.libgi import test_libgi_missing
|
||||||
from dzgui.config.query import lookup
|
|
||||||
from dzgui.config.userprefs import UserPrefs
|
|
||||||
from dzgui.config.xdg import get_xdg_paths, parse_filepaths
|
|
||||||
from dzgui.init.flock import lock_acquire
|
|
||||||
from dzgui.init.migrate import (
|
|
||||||
has_new_config,
|
|
||||||
copy_state_files,
|
|
||||||
migrate_cols_file,
|
|
||||||
)
|
|
||||||
from dzgui.init.prefix import get_version
|
from dzgui.init.prefix import get_version
|
||||||
from dzgui.init.prereqs import has_steam_client
|
from dzgui.util.strings import flags
|
||||||
from dzgui.strings import boot
|
|
||||||
|
|
||||||
# from dzgui.util.map_count import get_map_count
|
|
||||||
from dzgui.util.deck import is_steam_deck, is_game_mode
|
|
||||||
from dzgui.util.localize import set_locale
|
|
||||||
from dzgui.util.strings import init, flags
|
|
||||||
|
|
||||||
from dzgui.views.base import App
|
|
||||||
from dzgui.views.dialogs.boot import BootWindow
|
|
||||||
from dzgui.views.dialogs.early_alert import EarlyAlertDialog
|
|
||||||
from dzgui.views.dialogs.wizard import SetupWizard
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
logger = logging.getLogger(APP_NAME)
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description=flags.description)
|
parser = argparse.ArgumentParser(description=flags.description)
|
||||||
parser.add_argument("-v", "--version", action="store_true", help=flags.version)
|
parser.add_argument("-v", "--version", action="store_true", help=flags.version)
|
||||||
@@ -43,11 +14,6 @@ parser.add_argument("-d", "--debug", action="store_true", help=flags.debug)
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
# TODO: profile load time
|
|
||||||
def make_parents(path: "Path") -> None:
|
|
||||||
path.parent.mkdir(parents=True, exist_ok=True)
|
|
||||||
|
|
||||||
|
|
||||||
def uninstall() -> None:
|
def uninstall() -> None:
|
||||||
# TODO: uninstall data files (-u)
|
# TODO: uninstall data files (-u)
|
||||||
# -u removes state, log, freedesktop
|
# -u removes state, log, freedesktop
|
||||||
@@ -57,21 +23,7 @@ def uninstall() -> None:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def setup_logger(log_path: "Path") -> None:
|
|
||||||
_format = (
|
|
||||||
"%(asctime)s␞%(levelname)s␞%(filename)s::%(funcName)s::%(lineno)s␞%(message)s"
|
|
||||||
)
|
|
||||||
fh = logging.FileHandler(log_path)
|
|
||||||
formatter = logging.Formatter(_format)
|
|
||||||
fh.setFormatter(formatter)
|
|
||||||
fh.setLevel(logging.DEBUG)
|
|
||||||
logger.setLevel(logging.DEBUG)
|
|
||||||
logger.addHandler(fh)
|
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
lock = lock_acquire() # noqa
|
|
||||||
|
|
||||||
if args.version is True:
|
if args.version is True:
|
||||||
print(get_version())
|
print(get_version())
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
@@ -82,60 +34,11 @@ def main() -> None:
|
|||||||
warnings.filterwarnings("default", category=DeprecationWarning)
|
warnings.filterwarnings("default", category=DeprecationWarning)
|
||||||
|
|
||||||
version = get_version()
|
version = get_version()
|
||||||
set_locale()
|
|
||||||
|
|
||||||
print(f"{APP_NAME} {version}")
|
print(f"{APP_NAME} {version}")
|
||||||
|
test_libgi_missing()
|
||||||
|
|
||||||
# NOTE: consider aborting this check if steam deck
|
# NOTE: only import ligbirepository modules after the above check
|
||||||
xdg_paths = get_xdg_paths()
|
from dzgui.app_init import load_gui
|
||||||
XDG = parse_filepaths(xdg_paths)
|
|
||||||
|
|
||||||
if XDG.resolution.parent.is_dir() is False:
|
load_gui(version, args.debug)
|
||||||
make_parents(XDG.resolution)
|
|
||||||
|
|
||||||
if XDG.debug.is_file() is False:
|
|
||||||
make_parents(XDG.debug)
|
|
||||||
|
|
||||||
_is_steam_deck = is_steam_deck()
|
|
||||||
_is_game_mode = is_game_mode() if _is_steam_deck else False
|
|
||||||
if _is_game_mode:
|
|
||||||
# NOTE: this may no longer be necessary on newer versions of SteamOS
|
|
||||||
del os.environ["GTK_IM_MODULE"]
|
|
||||||
|
|
||||||
if has_new_config(XDG.config) is False:
|
|
||||||
migrate_cols_file(XDG.columns)
|
|
||||||
copy_state_files(xdg_paths["XDG_STATE_HOME"])
|
|
||||||
# TODO: add logging inside wizard
|
|
||||||
SetupWizard(_is_steam_deck, XDG.config)
|
|
||||||
|
|
||||||
# NOTE: implies that setup wizard failed or was closed
|
|
||||||
if has_new_config(XDG.config) is False:
|
|
||||||
return
|
|
||||||
|
|
||||||
setup_logger(XDG.debug)
|
|
||||||
with open(XDG.debug, "w") as f:
|
|
||||||
f.truncate(0)
|
|
||||||
|
|
||||||
if _is_steam_deck is False:
|
|
||||||
# TODO: sudo escalation dialog
|
|
||||||
# count = get_map_count()
|
|
||||||
# TODO: move into module
|
|
||||||
if has_steam_client() is False:
|
|
||||||
EarlyAlertDialog(init.requires_steam)
|
|
||||||
|
|
||||||
bootwin = BootWindow(XDG, version)
|
|
||||||
local_coords, latest_release = bootwin.get_results()
|
|
||||||
|
|
||||||
use_miles = lookup(XDG.config, Preferences.DIST)
|
|
||||||
prefs = UserPrefs(
|
|
||||||
is_steam_deck=_is_steam_deck,
|
|
||||||
is_game_mode=_is_game_mode,
|
|
||||||
is_debug=args.debug,
|
|
||||||
coords=local_coords,
|
|
||||||
version=version,
|
|
||||||
paths=XDG,
|
|
||||||
latest_release=latest_release,
|
|
||||||
use_miles=use_miles,
|
|
||||||
)
|
|
||||||
print(boot.all_ok)
|
|
||||||
App(prefs)
|
|
||||||
@@ -35,7 +35,11 @@ from dzgui.const.constants import (
|
|||||||
from dzgui.const.enum import NotebookPage, Preferences
|
from dzgui.const.enum import NotebookPage, Preferences
|
||||||
from dzgui.init.proc import is_dayz_running, is_steam_running
|
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.strings.dialogs import waiting_for_launch, waiting_for_mods, waiting_for_directories
|
from dzgui.strings.dialogs import (
|
||||||
|
waiting_for_launch,
|
||||||
|
waiting_for_mods,
|
||||||
|
waiting_for_directories,
|
||||||
|
)
|
||||||
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
|
||||||
@@ -144,21 +148,14 @@ class ConnectionManager:
|
|||||||
remote_mods: list[list[str]] = []
|
remote_mods: list[list[str]] = []
|
||||||
if res.is_modded():
|
if res.is_modded():
|
||||||
try:
|
try:
|
||||||
remote_mods = self._query_modlist(record)
|
remote_mods, missing_mods = self._query_modlist(record)
|
||||||
|
self.missing_mods = missing_mods
|
||||||
self.remote_mod_ids = [mod[1] for mod in remote_mods]
|
self.remote_mod_ids = [mod[1] for mod in remote_mods]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(e)
|
logger.warning(e)
|
||||||
self.thread_man.set_cleanup_func(failure_func, destroy_first=True)
|
self.thread_man.set_cleanup_func(failure_func, destroy_first=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
hashes = get_remote_signatures(self.remote_mod_ids)
|
|
||||||
version_file = prefs.paths.version
|
|
||||||
self.missing_mods = get_needs_update(version_file, hashes)
|
|
||||||
|
|
||||||
for mod in remote_mods:
|
|
||||||
if any(mod[1] in tuple for tuple in self.missing_mods):
|
|
||||||
mod[2] = resync
|
|
||||||
|
|
||||||
if local_version is not None:
|
if local_version is not None:
|
||||||
pefile_path = PeFile.get_pefile_path(steam_path, info.game_id)
|
pefile_path = PeFile.get_pefile_path(steam_path, info.game_id)
|
||||||
total, used, free = shutil.disk_usage(pefile_path)
|
total, used, free = shutil.disk_usage(pefile_path)
|
||||||
@@ -222,10 +219,13 @@ class ConnectionManager:
|
|||||||
StoredFunc(self._present_details_dialog, details), destroy_first=True
|
StoredFunc(self._present_details_dialog, details), destroy_first=True
|
||||||
)
|
)
|
||||||
|
|
||||||
def _query_modlist(self, record: Servers.Record) -> list[list[str]]:
|
def _query_modlist(
|
||||||
|
self, record: Servers.Record
|
||||||
|
) -> tuple[list[list[str]], list[tuple[str, str, int, int]]]:
|
||||||
mods = Servers.get_rules(record)
|
mods = Servers.get_rules(record)
|
||||||
steam_path = self.controller.query_config(Preferences.DEFAULT)
|
steam_path = self.controller.query_config(Preferences.DEFAULT)
|
||||||
local = get_local_mod_ids(steam_path)
|
local = get_local_mod_ids(steam_path)
|
||||||
|
|
||||||
alpha_mods: list[list[str]] = [
|
alpha_mods: list[list[str]] = [
|
||||||
[
|
[
|
||||||
mod.name,
|
mod.name,
|
||||||
@@ -235,12 +235,23 @@ class ConnectionManager:
|
|||||||
for mod in mods
|
for mod in mods
|
||||||
]
|
]
|
||||||
alpha_mods.sort(key=lambda x: x[0])
|
alpha_mods.sort(key=lambda x: x[0])
|
||||||
return alpha_mods
|
|
||||||
|
prefs = self.controller.get_prefs()
|
||||||
|
version_file = prefs.paths.version
|
||||||
|
|
||||||
|
remote_mod_ids = [mod[1] for mod in alpha_mods]
|
||||||
|
hashes = get_remote_signatures(remote_mod_ids)
|
||||||
|
missing_mods = get_needs_update(version_file, hashes)
|
||||||
|
for mod in alpha_mods:
|
||||||
|
if any(mod[1] in tuple for tuple in missing_mods):
|
||||||
|
mod[2] = resync
|
||||||
|
|
||||||
|
return alpha_mods, missing_mods
|
||||||
|
|
||||||
@call_on_thread(dialog.querying)
|
@call_on_thread(dialog.querying)
|
||||||
def query_modlist_and_present(self, record: Servers.Record) -> None:
|
def query_modlist_and_present(self, record: Servers.Record) -> None:
|
||||||
try:
|
try:
|
||||||
mods = self._query_modlist(record)
|
mods, missing_mods = self._query_modlist(record)
|
||||||
except Exception:
|
except Exception:
|
||||||
self.thread_man.set_cleanup_func(
|
self.thread_man.set_cleanup_func(
|
||||||
StoredFunc(self._server_timeout), destroy_first=True
|
StoredFunc(self._server_timeout), destroy_first=True
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ class FilterManager:
|
|||||||
if maps is None:
|
if maps is None:
|
||||||
return
|
return
|
||||||
if len(maps) < 1:
|
if len(maps) < 1:
|
||||||
|
self.reinit_map_store()
|
||||||
return
|
return
|
||||||
|
|
||||||
self.reinit_map_store()
|
self.reinit_map_store()
|
||||||
|
|||||||
@@ -395,8 +395,10 @@ class ServerModelManager:
|
|||||||
self.first_iteration = False
|
self.first_iteration = False
|
||||||
|
|
||||||
def _cleanup_on_success(self) -> None:
|
def _cleanup_on_success(self) -> None:
|
||||||
proxy = self._get_proxy_man().get_proxy_model()
|
proxy = self.proxy_man.get_proxy_model()
|
||||||
self.tv.set_model(proxy)
|
self.tv.set_model(proxy)
|
||||||
|
if self.preserve_on_fail is True:
|
||||||
|
self.proxy_man.wipe_cache()
|
||||||
|
|
||||||
self.emitter.emit("servers_loaded", self.enum)
|
self.emitter.emit("servers_loaded", self.enum)
|
||||||
if self.first_iteration:
|
if self.first_iteration:
|
||||||
|
|||||||
@@ -130,7 +130,6 @@ servers = {
|
|||||||
"Enter/space/double-click": "connect to server",
|
"Enter/space/double-click": "connect to server",
|
||||||
"Right-click/Ctrl-l": "additional context menus",
|
"Right-click/Ctrl-l": "additional context menus",
|
||||||
"Ctrl-r": "refresh players",
|
"Ctrl-r": "refresh players",
|
||||||
"Ctrl-p": "refresh ping",
|
|
||||||
"Ctrl-f": "jump to keyword search field",
|
"Ctrl-f": "jump to keyword search field",
|
||||||
"Ctrl-m": "jump to maps field",
|
"Ctrl-m": "jump to maps field",
|
||||||
"Ctrl-d": "select default LAN port",
|
"Ctrl-d": "select default LAN port",
|
||||||
@@ -148,8 +147,8 @@ servers = {
|
|||||||
vim = {
|
vim = {
|
||||||
"j": "Move down a row/scroll up",
|
"j": "Move down a row/scroll up",
|
||||||
"k": "Move up a row/scroll down",
|
"k": "Move up a row/scroll down",
|
||||||
"l": "Jump to main area from sidebar",
|
"h": "Jump to main area from sidebar",
|
||||||
"h": "Jump to sidebar from main area",
|
"l": "Jump to sidebar from main area",
|
||||||
"g": "Jump to first row/top of page",
|
"g": "Jump to first row/top of page",
|
||||||
"G": "Jump to last row/bottom of page",
|
"G": "Jump to last row/bottom of page",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,6 +141,8 @@ class RefreshButton(IconTextButton):
|
|||||||
|
|
||||||
def _on_refresh_clicked(self, button: Self) -> None:
|
def _on_refresh_clicked(self, button: Self) -> None:
|
||||||
"""Spawned in a thread"""
|
"""Spawned in a thread"""
|
||||||
|
if self.controller.get_active_treeview().is_loaded() is False:
|
||||||
|
return
|
||||||
self.is_clicked = True
|
self.is_clicked = True
|
||||||
self.controller.refresh_tree()
|
self.controller.refresh_tree()
|
||||||
# TODO: get server tab enum
|
# TODO: get server tab enum
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ description = "DayZ server browser and mod manager for Linux"
|
|||||||
authors = [
|
authors = [
|
||||||
{name = "aclist"}
|
{name = "aclist"}
|
||||||
]
|
]
|
||||||
version = "7.0.0b13"
|
version = "7.0.0b15"
|
||||||
license = "GPL-3.0-or-later"
|
license = "GPL-3.0-or-later"
|
||||||
license-files = ["LICENSE"]
|
license-files = ["LICENSE"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
import pytest
|
||||||
|
import tempfile
|
||||||
|
import os
|
||||||
|
|
||||||
|
from dzgui.app_init import copy_bare_configs
|
||||||
|
from dzgui.config.xdg import get_xdg_paths, parse_filepaths
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
CONF_STRING = "DZGUI_CONF\n"
|
||||||
|
STATE_STRING = "DZGUI_STATE\n"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def state_files():
|
||||||
|
state = [
|
||||||
|
"dzg.history",
|
||||||
|
"dzg.versions",
|
||||||
|
"dzg.res.json",
|
||||||
|
"dzg.filters.json",
|
||||||
|
"dzg.columns.json",
|
||||||
|
"dzg.notes.json",
|
||||||
|
"ips.csv",
|
||||||
|
".month",
|
||||||
|
]
|
||||||
|
return state
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def xdg_paths():
|
||||||
|
paths = []
|
||||||
|
routes = {
|
||||||
|
"XDG_CONFIG_HOME": "",
|
||||||
|
"XDG_STATE_HOME": "",
|
||||||
|
"XDG_DATA_HOME": "",
|
||||||
|
"XDG_CACHE_HOME": "",
|
||||||
|
}
|
||||||
|
for route in routes:
|
||||||
|
tmp = tempfile.TemporaryDirectory(delete=False)
|
||||||
|
routes[route] = tmp.name
|
||||||
|
for k, v in routes.items():
|
||||||
|
os.environ[k] = v
|
||||||
|
env = get_xdg_paths()
|
||||||
|
return parse_filepaths(env)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.mods
|
||||||
|
def test_config_file_import(xdg_paths, state_files):
|
||||||
|
|
||||||
|
# NOTE: write bare files in root
|
||||||
|
tmp_conf = xdg_paths.config.parent.parent
|
||||||
|
tmp_conf_file = tmp_conf / xdg_paths.config.name
|
||||||
|
tmp_conf_file.write_text(CONF_STRING)
|
||||||
|
|
||||||
|
tmp_state = xdg_paths.resolution.parent.parent
|
||||||
|
for file in state_files:
|
||||||
|
tmp_state.joinpath(file).write_text(STATE_STRING)
|
||||||
|
# NOTE: function should move files into "dzgui" subdirectory
|
||||||
|
config_changed, state_changed = copy_bare_configs(
|
||||||
|
xdg_paths.config, xdg_paths.resolution
|
||||||
|
)
|
||||||
|
|
||||||
|
assert xdg_paths.config.read_text() == CONF_STRING
|
||||||
|
for file in state_files:
|
||||||
|
expected = xdg_paths.resolution.parent.joinpath(file)
|
||||||
|
assert expected.read_text() == STATE_STRING
|
||||||
|
|
||||||
|
assert config_changed is True
|
||||||
|
assert state_changed is True
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.mods
|
||||||
|
def test_config_file_no_import(xdg_paths, state_files):
|
||||||
|
for subdir in xdg_paths.config.parent, xdg_paths.resolution.parent:
|
||||||
|
subdir.mkdir()
|
||||||
|
|
||||||
|
tmp_conf_file = xdg_paths.config
|
||||||
|
tmp_conf_file.write_text(CONF_STRING)
|
||||||
|
|
||||||
|
for file in state_files:
|
||||||
|
xdg_paths.resolution.parent.joinpath(file).write_text(STATE_STRING)
|
||||||
|
|
||||||
|
config_changed, state_changed = copy_bare_configs(
|
||||||
|
xdg_paths.config, xdg_paths.resolution
|
||||||
|
)
|
||||||
|
assert config_changed is False
|
||||||
|
assert state_changed is False
|
||||||
Reference in new issue
Block a user