chore: clear errors

This commit is contained in:
aclist 2026-05-05 22:46:16 +09:00
parent f3ad104b1b
commit e64feac425
19 changed files with 56 additions and 72 deletions

View File

@ -110,21 +110,21 @@ def get_missing_mods(local: list, remote: list) -> list:
return [mod for mod in remote if mod not in local]
# FIXME: steam path is missing when comparing to local mods
def get_server_modlist(server: Record, steam: Path) -> list:
try:
rules = dayzquery.dayz_rules((server.ip, server.qport))
except Exception as e:
raise e
remote_mods = [[mod.name, mod.workshop_id] for mod in rules.mods]
remote_mods.sort(key=lambda row: row[0])
local_mods = get_local_mod_ids(steam)
for mod in remote_mods:
if mod[1] in local_mods:
mod.append(checkmark)
else:
mod.append("")
return remote_mods
# TODO: drop
# def get_server_modlist(server: Record, steam: Path) -> list:
# try:
# rules = dayzquery.dayz_rules((server.ip, server.qport))
# except Exception as e:
# raise e
# remote_mods = [[mod.name, mod.workshop_id] for mod in rules.mods]
# remote_mods.sort(key=lambda row: row[0])
# local_mods = get_local_mod_ids(steam)
# for mod in remote_mods:
# if mod[1] in local_mods:
# mod.append(checkmark)
# else:
# mod.append("")
# return remote_mods
def _hash(uid: str) -> str:

View File

@ -436,18 +436,11 @@ def validate_ip(addr: str) -> Record:
return record
# TODO: do not return empty list in event of failure
def get_rules(record: Record) -> list["DayzMod"]:
ip = record.ip
qport = record.qport
#try:
mods = dayzquery.dayz_rules((ip, qport)).mods
return [mod for mod in mods]
#except Exception as e:
# logger.critical(e)
# raise e
# TODO: supposed to skip failing servers for highlight action
#return []
def query_by_id(addr: str, key: str, full: bool = False) -> dict[Any] | None:

View File

@ -37,7 +37,7 @@ logger = logging.getLogger(APP_NAME)
if TYPE_CHECKING:
from dayzquery import DayzMod
from dzgui.api.servers import Record
from dzgui.api.servers import PreReqs, Record
from dzgui.const.enum import ServerTab
from dzgui.managers.filter import FilterManager
from dzgui.util.dist import Haversine
@ -458,7 +458,7 @@ class Controller(GObject.GObject):
def set_exit_event(self) -> None:
self.exit_event.set()
def open_connection_assistant(self, res: dict[Any], mods: list["DayzMod"]) -> None:
def open_connection_assistant(self, res: "PreReqs", mods: list["DayzMod"]) -> None:
self.open_page(NotebookPage.CONNECTION)
self.mediator.preconnect.populate(res, mods)
# TODO: populate assistant

View File

@ -11,8 +11,7 @@ def migrate_legacy_conf(config: Path) -> None:
old_conf = Path.home() / LEGACY_CONFIG_PATH
if old_conf.is_file():
j = rc2json(old_conf)
# FIXME: superfluous use of Path()
Path(config).parent.mkdir(parents=True, exist_ok=True)
config.parent.mkdir(parents=True, exist_ok=True)
config.write_text(j)
else:
print("Unimplemented. You must have a working dztuirc.")

View File

@ -133,6 +133,7 @@ def main() -> None:
is_dayz_running()
is_steam_running()
# NOTE: clear versions file of unlinked mods
rebuild_symlinks(XDG.config)
remove_stale_signatures(XDG.config, XDG.version)

View File

@ -55,7 +55,6 @@ class ConnectionManager:
info = res.source
try:
# TODO: proper error handling (currently returns empty list)
mods = self._query_modlist(record)
except Exception:
self.thread_man.set_cleanup_func(failure_func, destroy_first=True)
@ -94,13 +93,6 @@ class ConnectionManager:
mods = Servers.get_rules(record)
steam_path = self.controller.query_config(Preferences.DEFAULT)
local = get_local_mod_ids(steam_path)
# if len(mods) == 0:
# # TODO: separate message for no mods
# # TODO: separate message for actual timeout
# self.thread_man.set_cleanup_func(
# StoredFunc(self._server_timeout), destroy_first=True
# )
# return
alpha_mods = [
[
mod.name,

View File

@ -180,14 +180,7 @@ class ModManager:
# TODO: strings
@call_on_thread("working")
def highlight_stale(self) -> None:
# try:
stale = find_stale_mods(self.prefs.paths.config)
# except Exception:
# # TODO: clearer error message
# func = StoredFunc(self._server_timeout)
# self.thread_man.set_cleanup_func(func)
# return
func = StoredFunc(self._on_stale_mods_found, stale)
self.thread_man.set_cleanup_func(func)

View File

@ -328,10 +328,8 @@ class ServerModelManager:
ips = config_man.lookup(Preferences.IP_LIST)
self.thread_man.set_job_count(len(ips))
# TODO: customize statusbar to mention how records can be added via contextmenu
if len(ips) == 0:
# FIXME: this is not a failure, just a quiet exit with custom statusbar
# TODO: add custom statusbar parameters
# TODO: customize statusbar to mention how records can be added via contextmenu
self.thread_man.set_cleanup_func(
StoredFunc(self._cleanup_on_failure, False)
)

View File

@ -28,19 +28,18 @@ def rebuild_symlinks(config: Path) -> None:
source = Path(dayz_path / md5sum)
if source.exists() is False:
source.symlink_to(workshop / uid)
clone_symlinks(steam_path)
def clone_symlinks(config: Path) -> None:
def clone_symlinks(steam_path: Path) -> None:
"""
Used after any symlink operation
"""
path = lookup(config, Preferences.DEFAULT)
steam_path = Path(path)
try:
dayz_path = PeFile.get_nested_app_path(steam_path, APPID_DAYZ)
exp_path = PeFile.get_nested_app_path(steam_path, APPID_DAYZ_EXP)
except Exception as e:
logger.critical(e)
logger.warning(e)
return
# TODO: test these two operations

View File

@ -161,15 +161,18 @@ class Notebook(ScrollableMixin, Gtk.Notebook): # type: ignore
self.connect_after("switch-page", self._on_page_changed)
self.connect("key-press-event", self._on_keypress)
def _on_keypress(self, widget: Gtk.Widget, event: Gdk.EventKey) -> None:
def _on_keypress(self, widget: Gtk.Widget, event: Gdk.EventKey) -> bool:
match event.keyval:
case Gdk.KEY_Right | Gdk.KEY_l:
# FIXME: propagation bool
if event.state is Gdk.ModifierType.CONTROL_MASK:
return
return False
MainController.get_emitter().emit("request_button_box_focus")
return True
case Gdk.KEY_question:
self.toggle_keybindings()
return True
case _:
return False
def return_prior(self) -> None:
"""

View File

@ -53,7 +53,6 @@ class ButtonBox(Gtk.Box):
context=side_button,
)
# FIXME: if debug log fails to load, still opens table
size = (10, 10) if prefs.is_steam_deck else (50, 50)
x, y = size
button.set_size_request(x, y)

View File

@ -126,7 +126,6 @@ class WaitDialog(GenericDialog):
class QuitDialog(GenericDialog):
def __init__(self, controller: "Controller", secondary: str):
# FIXME: do not pass controller to every dialog
super().__init__(
controller=controller,
text=strings.wait,
@ -173,6 +172,7 @@ class ExceptionDialog(GenericDialog):
propagate_natural_height=True, max_content_height=500
)
box = Gtk.Box(hexpand=True, vexpand=True, orientation=Gtk.Orientation.VERTICAL)
# TODO: wrap/truncate long messages
textview = Gtk.TextView(
wrap_mode=Gtk.WrapMode.WORD, editable=False, left_margin=10, right_margin=10
)
@ -182,7 +182,7 @@ class ExceptionDialog(GenericDialog):
content = self.get_content_area()
content.set_spacing(0)
# FIXME: padding around top of content area when traceback is long
# TODO: padding around top of content area when traceback is long
content.add(scrollable)
copy_button = ClipboardButton(controller, self.get_trace)

View File

@ -60,7 +60,7 @@ class ServerModDialog(GenericDialog):
dialogBox.pack_end(self.scrollable, EXPAND, FILL, 0)
mod_count = len(mods)
self.set_markup(f"Modlist ({mod_count} mods")
self.set_markup(f"Modlist ({mod_count} mods)")
for mod in mods:
self.mod_store.append(mod)

View File

@ -1,10 +1,11 @@
from typing import Self, TYPE_CHECKING
from dzgui.const.constants import EXPAND, FILL, NO_PADDING
from dzgui.const.constants import EXPAND, FILL
from dzgui.model.model_factory import ModelFactory
from dzgui.util import css
from dzgui.util import strings
from dzgui.util.format import format_hyperlinks, format_server_mods
from dzgui.strings import server_mods
from dzgui.views.dialogs.generic import GenericDialog
from dzgui.views.trees.tree_base import TreeView
@ -121,7 +122,7 @@ class ServerModDialog(ServerDialog):
def __init__(self, controller: "Controller", mods: list[list[str]]):
name = controller.get_server_name()
super().__init__(controller, strings.modlist, name)
super().__init__(controller, server_mods.modlist, name)
self.controller = controller
self.mod_store = ModelFactory().make_server_mod_store()
@ -130,17 +131,22 @@ class ServerModDialog(ServerDialog):
self.view.set_model(self.mod_store)
self.view.connect("row-activated", self._on_row_activated)
for i, column_title in enumerate(strings.server_mod_cols):
# TODO: inherit from ServerModTreeView
columns = [
server_mods.mod,
server_mods.mod_id,
server_mods.installed,
]
for i, column_title in enumerate(columns):
renderer = Gtk.CellRendererText(ellipsize=Pango.EllipsizeMode.END)
column = Gtk.TreeViewColumn(column_title, renderer, text=i)
column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
self.view.append_column(column)
column.set_sort_column_id(i)
# FIXME: do not recycle generic string vars
match column_title:
case strings.mod:
case server_mods.mod:
column.set_fixed_width(350)
case strings._id:
case server_mods.mod_id:
column.set_fixed_width(200)
case _:
pass

View File

@ -82,7 +82,6 @@ class ContextMixin(TreeView):
(path, col, cellx, celly) = pathinfo
if path is None:
return True
# return True
selection = self.get_selection()
model, selected_paths = selection.get_selected_rows()
if path not in selected_paths:
@ -90,7 +89,6 @@ class ContextMixin(TreeView):
selection.unselect_path(p)
self.set_cursor(path, col, False)
return True
# FIXME: if selection is not multiple, change cursor
except AttributeError:
return False

View File

@ -20,6 +20,7 @@ from dzgui.const.constants import (
)
from dzgui.const.endpoints import STEAM_API_SETUP, BM_API_SETUP
from dzgui.const.enum import Preferences, ServerTab
from dzgui.strings import errors
from dzgui.util import strings, css, open_links
from dzgui.views.components.labels import LeftLabel
from dzgui.views.components.eventbox import InfoEventBox
@ -300,8 +301,7 @@ class Options(Gtk.Box):
def _on_api_change_failed(self, emitter: "Emitter") -> None:
self.old_entry.set_text(self.old_text)
# FIXME: ambiguous error message
dialog = ExceptionDialog(self.controller, strings.api_error)
dialog = ExceptionDialog(self.controller, errors.api_validation_error)
dialog.run()
def restore_api_text(self, text: str, entry: Gtk.Entry) -> None:

View File

@ -19,7 +19,7 @@ from dzgui.views.trees.tree_server_mods import ServerModTreeView
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk # type: ignore # noqa E402
from gi.repository import Gdk, Gtk # type: ignore # noqa E402
if TYPE_CHECKING:

View File

@ -47,7 +47,6 @@ class MenuTreeView(TreeView):
def _parent_row_activated(
self, tree: TreeView, path: Gtk.TreePath, column: Gtk.TreeViewColumn
) -> None:
# FIXME: may be expected to return str, not enum
row_type = self.get_value_at_index(1)
match row_type:

View File

@ -1,8 +1,8 @@
from dzgui.const.enum import ContextMenuGroup
from dzgui.model.model_factory import ModelFactory
from dzgui.strings import server_mods
from dzgui.views.mixins.context_mixin import ContextMixin
from dzgui.views.trees.tree_base import TreeView
from dzgui.util import strings
from typing import TYPE_CHECKING
@ -29,17 +29,21 @@ class ServerModTreeView(ContextMixin, TreeView): # type: ignore
self.connect("key-press-event", self.present_menu)
self.connect("row-activated", self._on_row_activated)
for i, column_title in enumerate(strings.server_mod_cols):
columns = [
server_mods.mod,
server_mods.mod_id,
server_mods.installed,
]
for i, column_title in enumerate(columns):
renderer = Gtk.CellRendererText(ellipsize=Pango.EllipsizeMode.END)
column = Gtk.TreeViewColumn(column_title, renderer, text=i)
column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
self.append_column(column)
column.set_sort_column_id(i)
# FIXME: do not recycle generic string vars
match column_title:
case strings.mod:
case server_mods.mod:
column.set_fixed_width(350)
case strings._id:
case server_mods.mod_id:
column.set_fixed_width(200)
case _:
pass