chore: drop unused code

This commit is contained in:
aclist 2026-04-19 18:58:05 +09:00
parent 107c672b1c
commit 891abcc049
4 changed files with 14 additions and 86 deletions

View File

@ -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:

View File

@ -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)

View File

@ -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)

View File

@ -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()