Compare commits

..

No commits in common. "5532e4e267e4dbb2bee05e95180d981572255f30" and "65e11ddd0384b3800ffd5c50039bb3e12fb54753" have entirely different histories.

9 changed files with 54 additions and 73 deletions

View File

@ -21,7 +21,6 @@ from dzgui.strings import boot
from dzgui.util.deck import is_steam_deck, is_game_mode
from dzgui.util.dirs import make_parents
from dzgui.util.localize import set_locale
from dzgui.util.map_count import test_map_count
from dzgui.util.redact import RedactionFilter, REDACTION_PATTERNS
from dzgui.util.strings import init
@ -119,7 +118,6 @@ def load_gui(version: str, is_debug: bool) -> None:
del os.environ["GTK_IM_MODULE"]
if has_new_config(XDG.config) is False:
test_map_count()
migrate_cols_file(XDG.columns)
copy_state_files(xdg_paths["XDG_STATE_HOME"])
# TODO: add logging inside wizard

View File

@ -5,14 +5,14 @@ import warnings
from dzgui.const.constants import APP_NAME
from dzgui.init.libgi import test_libgi_missing
from dzgui.init.prefix import get_version
from dzgui.util.map_count import set_map_count
from dzgui.util.map_count import set_map_count, test_map_count
from dzgui.util.strings import flags
parser = argparse.ArgumentParser(description=flags.description)
parser.add_argument("-v", "--version", action="store_true", help=flags.version)
parser.add_argument("-u", "--uninstall", action="store_true", help=flags.uninstall)
parser.add_argument("-d", "--debug", action="store_true", help=flags.debug)
parser.add_argument("-m", "--map", action="store_true", help=flags.map_count)
parser.add_argument("-u", "--uninstall", action="store_true", help=flags.uninstall)
parser.add_argument("-v", "--version", action="store_true", help=flags.version)
args = parser.parse_args()
@ -39,6 +39,7 @@ def main() -> None:
set_map_count()
sys.exit(0)
test_map_count()
version = get_version()
print(f"{APP_NAME} {version}")

View File

@ -21,11 +21,11 @@ class FilterManager:
strings.filter_3pp: True,
strings.filter_night: True,
strings.filter_full: show_full,
strings.filter_official: True,
strings.filter_nonascii: False,
strings.filter_lowpop: True,
strings.filter_unofficial: True,
strings.filter_nonascii: False,
strings.filter_duplicate: False,
strings.filter_official: True,
strings.filter_unofficial: True,
strings.filter_modded: True,
}

View File

@ -1,16 +0,0 @@
exit_msg = (
"System map count is not high enough to run DayZ. "
"Please exit and run 'dzgui -m' to update map count."
)
failed_to_parse = (
"Failed to parse system map count.\n"
"This usually indicates that systemd is not installed."
)
failed_to_update = (
"Failed to update system map count.\n"
"Please report the issue upstream and provide the following traceback.\n\n"
"{0}"
)
meets_minimum = "System map count of {0} already meets the minimum."
prompt = "Updated map count will be written to the file {0}."
user_exit = "User exit"

View File

@ -54,6 +54,8 @@ def write_diagnostic(config: Path, outfile: Path) -> None:
cpu = get_cpu_model()
version = get_version()
debug = lookup(config, Preferences.DEBUG)
install = lookup(config, Preferences.INSTALL)
default = lookup(config, Preferences.DEFAULT)
steam_path = Path(default)
@ -77,6 +79,8 @@ def write_diagnostic(config: Path, outfile: Path) -> None:
Kernel: {kernel}
CPU: {cpu}
Debug: {debug}
Auto-install: {install}
Steam path: {steam_redacted}
Workshop path: {workshop_redacted}

View File

@ -1,19 +1,15 @@
import logging
import subprocess
import sys
import tempfile
import traceback
from pathlib import Path
from dzgui.const.constants import APP_NAME, VM_FILE, MIN_COUNT
from dzgui.const.constants import VM_FILE, MIN_COUNT
from dzgui.util.bash import concat_bash_args
from dzgui.strings import map_count
from dzgui.views.dialogs.early_alert import EarlyIgnoreDialog
logger = logging.getLogger(APP_NAME)
def is_map_count_valid(count: int | None) -> bool:
def is_map_count_valid() -> bool:
count = get_map_count()
if count is None:
# NOTE: permit if count was unreadable
return True
@ -22,50 +18,47 @@ def is_map_count_valid(count: int | None) -> bool:
def get_map_count() -> int | None:
path = Path(VM_FILE)
try:
count = int(path.read_text())
except Exception as e:
logger.debug(e)
if path.is_file() is False:
return None
count = int(path.read_text())
return count
def test_map_count() -> None:
count = get_map_count()
if is_map_count_valid(count):
if is_map_count_valid():
return
msg = map_count.exit_msg
msg = (
"System map count is not high enough to run DayZ.\n"
"Please exit and run 'dzgui -m' to update map count."
)
EarlyIgnoreDialog(msg)
def set_map_count() -> None:
count = get_map_count()
if count is None:
print(map_count.failed_to_parse)
valid = is_map_count_valid()
if valid is None:
return
if is_map_count_valid(count):
msg = map_count.meets_minimum.format(count)
print(msg)
elif valid:
print("System map count already meets the minimum.")
return
conf = "/etc/sysctl.d/dayz.conf"
value = f"vm.max_map_count={MIN_COUNT}"
count = f"vm.max_map_count={MIN_COUNT}"
try:
msg = map_count.prompt.format(conf)
msg = (
f"Updated map count will be written to the file '{conf}'.\n"
"Enter sudo password to proceed."
)
print(msg)
with tempfile.NamedTemporaryFile(delete=False) as f:
tmp = f.name
Path(tmp).write_text(value)
mv_cmd = f"sudo mv {tmp} {conf}"
reload_cmd = f"sudo sysctl -p {conf}"
for cmd in mv_cmd, reload_cmd:
args = concat_bash_args(cmd)
subprocess.run([*args])
Path(tmp).write_text(count)
args = concat_bash_args(f"sudo mv {tmp} {conf}")
subprocess.run([*args])
args = concat_bash_args(f"sudo sysctl -p {conf}")
subprocess.run([*args])
except Exception as e:
logger.debug(e)
trace = traceback.format_exc()
print(map_count.failed_to_update.format(trace))
print(e)
except KeyboardInterrupt:
print(map_count.user_exit)
print("User exit")
sys.exit(0)

View File

@ -472,10 +472,10 @@ class Flags:
flags = Flags(
description="DayZ server browser and mod manager",
version="print version information",
uninstall="clean up state/config files",
debug="enable developer debugging features",
map_count="check and update system map count value",
version="Print version information",
uninstall="Clean up state/config files",
debug="Enable developer debugging features",
map_count="Check and update system map count value"
)
@ -543,7 +543,9 @@ connect_panel = ConnectPanel(
add="Add",
add_con="Add/connect",
placeholder="Enter IP (IP:Query port)",
entry_tooltip=("- IP: format as IP:Query port\ne.g. 192.168.1.1:27016"),
entry_tooltip=(
"- IP: format as IP:Query port\ne.g. 192.168.1.1:27016"
),
add_tooltip="Add to Saved Servers",
connect_tooltip="Connect to this server",
)

View File

@ -33,15 +33,15 @@ class ButtonGrid(Gtk.Grid):
super().__init__(
halign=Gtk.Align.CENTER, column_spacing=5, column_homogeneous=True
)
row = 1
col = 0
self.controller = controller
self.emitter = controller.get_emitter()
self.checks: list[Gtk.CheckButton] = []
flowbox = Gtk.FlowBox(
halign=Gtk.Align.CENTER, min_children_per_line=3, max_children_per_line=3
)
# TODO: use enumerated checks
for check in defaults.keys():
checkbox = Gtk.CheckButton(label=check)
label = checkbox.get_child()
@ -51,12 +51,14 @@ class ButtonGrid(Gtk.Grid):
if defaults[check]:
checkbox.set_active(True)
col = col + 1
if col > 3:
row += 1
col = 1
self.attach(checkbox, col, row, 1, 1)
checkbox.connect("toggled", self._on_check_toggled)
flowbox.add(checkbox)
self.checks.append(checkbox)
self.add(flowbox)
def block_toggles(self, state: bool) -> None:
for check in self.checks:
self.controller.suppress_signal(

View File

@ -22,10 +22,6 @@ class AbortDialog(Gtk.MessageDialog):
msg = textwrap.fill(string, 50)
self.format_secondary_text(msg)
ma = self.get_message_area()
label = ma.get_children()[1] # type: ignore
label.set_justify(Gtk.Justification.CENTER)
aa = self.get_action_area()
aa.set_margin_bottom(20)
aa.set_layout(Gtk.ButtonBoxStyle.CENTER) # type: ignore
@ -53,6 +49,7 @@ class AbortDialog(Gtk.MessageDialog):
case Gtk.ResponseType.OK | Gtk.ResponseType.DELETE_EVENT:
sys.exit(1)
case Gtk.ResponseType.CANCEL:
print("response was cancel")
return