From 891abcc0495306c31c855b01dcb3bb2f51787e7a Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Sun, 19 Apr 2026 18:58:05 +0900 Subject: [PATCH] chore: drop unused code --- dzgui/api/probe.py | 13 +++---- dzgui/api/servers.py | 5 ++- dzgui/main.py | 1 + dzgui/views/base.py | 81 ++------------------------------------------ 4 files changed, 14 insertions(+), 86 deletions(-) diff --git a/dzgui/api/probe.py b/dzgui/api/probe.py index d2ce200..0280502 100644 --- a/dzgui/api/probe.py +++ b/dzgui/api/probe.py @@ -8,18 +8,22 @@ from dzgui.const import endpoints logger = logging.getLogger(__name__) + if TYPE_CHECKING: from requests import Response + def test_steam_api(key: str) -> bool: appid = APPID_DAYZ payload: dict[str, Union[int, str]] = { - "filter": r"\appid" + fr"\{appid}", + "filter": r"\appid" + rf"\{appid}", "limit": 10, "key": key, } try: - res = requests.get(endpoints.STEAM_SERVERS, params=payload, timeout=REQUEST_TIMEOUT) + res = requests.get( + endpoints.STEAM_SERVERS, params=payload, timeout=REQUEST_TIMEOUT + ) return is_remote_up(res) except Exception as e: logger.critical(e) @@ -44,10 +48,7 @@ def test_bm_api(key: str) -> bool: hdr = {"Authorization": "Bearer " + key} try: res = requests.get( - endpoints.BM_SERVERS, - params=payload, - headers=hdr, - timeout=REQUEST_TIMEOUT + endpoints.BM_SERVERS, params=payload, headers=hdr, timeout=REQUEST_TIMEOUT ) return is_remote_up(res) except Exception as e: diff --git a/dzgui/api/servers.py b/dzgui/api/servers.py index 7aae579..4a34a55 100644 --- a/dzgui/api/servers.py +++ b/dzgui/api/servers.py @@ -21,9 +21,10 @@ import dayzquery logger = logging.getLogger(__name__) +logging.getLogger("a2s").setLevel(logging.ERROR) # TODO: confirm that patches from testing are incorporated here -# particularly around malformed values. check commit log +# particularly around malformed values in JSON response. check commit log params = [ r"\nor\1\map\chernarusplus\nor\1\map\sakhal\nor\1\map\enoch\empty\1\nor\1\map\namalsk", # noqa @@ -467,10 +468,12 @@ def query_playercount(record: Record) -> Optional[tuple[int]]: logger.critical(e) return None + def query_by_ip(addr: str) -> Optional[dict]: record = short_ip_to_record(addr) return query_by_record(record) + def query_by_record(record: Record) -> Optional[dict]: try: return query_direct(record.ip, record.qport) diff --git a/dzgui/main.py b/dzgui/main.py index 2f8127c..6d991dc 100644 --- a/dzgui/main.py +++ b/dzgui/main.py @@ -37,6 +37,7 @@ from dzgui.views.base import App from dzgui.views.dialogs.early_alert import EarlyAlertDialog, EarlyIgnoreDialog logger = logging.getLogger(__name__) + parser = argparse.ArgumentParser(description=flags.description) parser.add_argument("-v", "--version", action="store_true", help=flags.version) diff --git a/dzgui/views/base.py b/dzgui/views/base.py index de6476b..e54c3e6 100644 --- a/dzgui/views/base.py +++ b/dzgui/views/base.py @@ -4,7 +4,6 @@ import warnings from typing import TYPE_CHECKING, Literal -# TODO: import notebook only and add components there? from dzgui.const.constants import APP_NAME, APP_NAME_LOWER, STEAM_ICON from dzgui.const.enum import NotebookPage from dzgui.controllers.emitter import Emitter @@ -15,6 +14,8 @@ from dzgui.views.components.crumbs import Breadcrumbs from dzgui.views.components.right_panel import RightPanel from dzgui.views.components.statusbar import Statusbar from dzgui.views.mixins.scrollable_mixin import ScrollableMixin + +# TODO: import notebook only and add components there? from dzgui.views.pages.changelog import Changelog from dzgui.views.pages.devs import Developers from dzgui.views.pages.help import Help @@ -38,10 +39,6 @@ logger = logging.getLogger(__name__) warnings.filterwarnings("ignore", ".*g_value_get_int", Warning) -# TODO: move to controller -# kilometer cache; note, user may change measurement it partway through, flush cache -# cache: dict[str, int] = {} - ## TODO: move to configs/servers # def query_history() -> list | None: # history_file = MainController.get_prefs().paths.history @@ -52,38 +49,6 @@ warnings.filterwarnings("ignore", ".*g_value_get_int", Warning) # rows = None # return rows # -# def process_tree_option(choice: RowType) -> None: -# # server tables -# if command == RowType.RESOLVE_IP: -# record = treeview.get_record() -# wait_msg = command.dict["wait_msg"] -# show_wait_dialog = True -# -# # TODO: needs threading, this is a slow process -# # TODO: needs saving into config -# # TODO: used by add/remove servers -# real_ip = ip.resolve_ip(record) -# #call_on_thread( -# # show_wait_dialog, cmd_string, wait_msg, record, choice=choice -# #) -# return -# -# if command == RowType.QUICK_CONNECT: -# record = MainController.query_config(Preferences.FAV_SRV) -# if record == "": -# spawn_dialog("No favorite server currently set", Popup.NOTIFY) -# return -# -# record = str_to_record(record) -# thread_new_with_dialog( -# treeview.prepare_connection, -# parse_shell_output, -# "Querying server", -# command, -# [record], -# ) -# return -# ## TODO: belongs in model # def str_to_record(record: str) -> Record | None: # r = record.split(":") @@ -96,44 +61,6 @@ warnings.filterwarnings("ignore", ".*g_value_get_int", Warning) # return f"{record.ip}:{record.gameport}:{record.qport}" # # -# def connect_by_ip(enum: RowType, response: str) -> None: -# def _prep(response: str) -> None: -# record = Servers.validate_ip(response) -# proc = treeview.prepare_connection(record) -# return proc -# -# thread_new_with_dialog( -# _prep, parse_shell_output, "Querying IP", enum, [response] -# ) -# return -# -# -# def connect_by_id(enum: RowType, uid: str, key: str) -> None: -# def _prep(key: str, response: str) -> None: -# # TODO: if response is non numeric, raise dialog -# if response.isnumeric() is False: -# pass -# # raise error -# # raise BmIdError("ID must be numeric only") -# # return -# from dzgui.api.bm import map_id_to_record -# try: -# record = map_id_to_record(config, uid) -# except Exception as e: -# logger.critical(e) -# # raise dialog -# return -# # proc = treeview.prepare_connection(record) -# # return proc -# -# #thread_new_with_dialog( -# # _prep, parse_shell_output, "Querying API", enum, [key, response] -# #) -# #return -# -# - - class OuterWindow(Gtk.Window): def __init__(self) -> None: super().__init__(title=APP_NAME, border_width=10, icon_name=APP_NAME_LOWER) @@ -304,10 +231,6 @@ class Grid(Gtk.Grid): MainController.register_widget("grid", self) - # self.bu = Gtk.Button(label="Shrink to fit", halign=Gtk.Align.END) - # self.bu.connect("clicked", self._shrink) - # self.crumb_box.add(self.bu) - self.emitter = MainController.get_emitter() self.notebook = Notebook()