mirror of
https://github.com/aclist/dztui.git
synced 2026-08-29 19:27:13 +02:00
Compare commits
6 Commits
9d3aa8d9f5
...
c4cc9f04c4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c4cc9f04c4 | ||
|
|
bcd59162b1 | ||
|
|
2f0bac75ac | ||
|
|
9191f43c8e | ||
|
|
2419fedd19 | ||
|
|
83a7996189 |
@ -14,6 +14,7 @@ from typing import Any, Optional, TYPE_CHECKING, Union
|
||||
from dzgui.api.bm import map_id_to_record
|
||||
from dzgui.const.constants import APP_NAME, REQUEST_TIMEOUT
|
||||
from dzgui.const.endpoints import STEAM_SERVERS
|
||||
from dzgui.util.format import format_exception
|
||||
from dzgui.util import strings
|
||||
|
||||
import a2s
|
||||
@ -272,8 +273,9 @@ def source_info_to_dict(ip: str, qport: int, info: "SourceInfo") -> dict[str, An
|
||||
res["ping"] = ping
|
||||
return res
|
||||
except Exception as e:
|
||||
# TODO: generalized function
|
||||
logger.critical(f"{type(e).__name__}: {e} ({ip}:{qport})")
|
||||
msg = format_exception(e)
|
||||
msg += f" ({ip}:{qport})"
|
||||
logger.critical(msg)
|
||||
raise e
|
||||
|
||||
|
||||
|
||||
@ -238,8 +238,7 @@ class ConnectionManager:
|
||||
def query_modlist_and_present(self, record: Servers.Record) -> None:
|
||||
try:
|
||||
mods = self._query_modlist(record)
|
||||
except Exception as e:
|
||||
print(f"{type(e).__name__}: {e}")
|
||||
except Exception:
|
||||
self.thread_man.set_cleanup_func(
|
||||
StoredFunc(self._server_timeout), destroy_first=True
|
||||
)
|
||||
|
||||
@ -83,3 +83,7 @@ def format_player_count(model: Gtk.TreeModel | None, control: list) -> str:
|
||||
|
||||
def embolden(text: str) -> str:
|
||||
return f"<b>{text}</b>"
|
||||
|
||||
|
||||
def format_exception(e: Exception) -> str:
|
||||
return f"{type(e).__name__}: {e}"
|
||||
|
||||
@ -181,7 +181,7 @@ filter_lowpop = "Low pop"
|
||||
filter_nonascii = "Non-ASCII"
|
||||
filter_duplicate = "Duplicate"
|
||||
filter_official = "Official"
|
||||
filter_unofficial = "Unoffic."
|
||||
filter_unofficial = "Unofficial"
|
||||
filter_modded = "Modded"
|
||||
|
||||
# maps
|
||||
|
||||
@ -11,6 +11,7 @@ from dzgui.const.constants import (
|
||||
)
|
||||
from dzgui.const.enum import FilterMode
|
||||
from dzgui.model.servers import ServerModelManager
|
||||
from dzgui.util.format import format_exception
|
||||
from dzgui.util.strings import all_maps
|
||||
from dzgui.views.components.maps_combo import MapsCombo
|
||||
from dzgui.views.components.labels import BoldLabel
|
||||
@ -333,6 +334,10 @@ class FilterPanel(Gtk.Box):
|
||||
self.emitter.emit("map_selection_changed", name)
|
||||
|
||||
def set_filters(self, filters: dict[str, bool]) -> None:
|
||||
for check in self.button_grid.checks:
|
||||
label = check.get_label()
|
||||
check.set_active(filters[label])
|
||||
try:
|
||||
for check in self.button_grid.checks:
|
||||
label = check.get_label()
|
||||
check.set_active(filters[label])
|
||||
except Exception as e:
|
||||
msg = format_exception(e)
|
||||
logger.warning(msg)
|
||||
|
||||
@ -8,7 +8,7 @@ from dzgui.views.components.buttons import LoggerAlertsButton
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GObject # noqa E402
|
||||
from gi.repository import Gtk # noqa E402
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from dzgui.const.enum import ServerTab
|
||||
@ -34,14 +34,6 @@ class Statusbar(Gtk.Grid):
|
||||
self.attach(self.statusbar, 0, 0, 3, 1)
|
||||
self.attach_next_to(self.spinner, self.statusbar, Gtk.PositionType.RIGHT, 3, 1)
|
||||
|
||||
# TODO: pack version event box in right panel into hbox with update button
|
||||
# TODO: spawns a modal or just jumps right to install page
|
||||
# from dzgui.views.components.buttons import IconTextButton
|
||||
# b = IconTextButton("dialog-information-symbolic", label="Updates available")
|
||||
# b.set_halign(Gtk.Align.END)
|
||||
# b.set_hexpand(True)
|
||||
# self.attach_next_to(b, self.spinner, Gtk.PositionType.RIGHT, 3, 1)
|
||||
|
||||
self.players = ""
|
||||
|
||||
controller.get_menu().connect("generic_treesel_changed", self._help_row_changed)
|
||||
@ -92,12 +84,6 @@ class Statusbar(Gtk.Grid):
|
||||
|
||||
self.set_by_context(enum, bar)
|
||||
|
||||
# TODO: unused
|
||||
def _on_notebook_page_returned(
|
||||
self, statusbar: Self, prior_context: NotebookPage
|
||||
) -> None:
|
||||
self.pop(prior_context)
|
||||
|
||||
def _on_server_row_changed(self, statusbar: Self) -> None:
|
||||
self.spinner.start()
|
||||
|
||||
@ -132,12 +118,6 @@ class Statusbar(Gtk.Grid):
|
||||
cid = self.statusbar.get_context_id(str(context))
|
||||
self.statusbar.pop(cid)
|
||||
|
||||
@deprecated("currently unused")
|
||||
# def get_text(self) -> str:
|
||||
# area = self.statusbar.get_message_area()
|
||||
# label = area.get_children()[0]
|
||||
# return str(label.get_text())
|
||||
|
||||
def set_by_context(
|
||||
self, context: Union[NotebookPage, "ServerTab"], string: str
|
||||
) -> None:
|
||||
|
||||
@ -14,6 +14,7 @@ from dzgui.init.update import check_updates
|
||||
from dzgui.const.constants import EXPAND, FILL
|
||||
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
|
||||
from dzgui.strings import preboot
|
||||
from dzgui.util.format import format_exception
|
||||
from dzgui.util.strings import dialog_header
|
||||
from dzgui.util.symlink import rebuild_symlinks
|
||||
from dzgui.views.components.buttons import ClipboardButton
|
||||
@ -175,8 +176,7 @@ class BootDialog(Gtk.Dialog):
|
||||
self.thread_man.set_cleanup_func(callback)
|
||||
except Exception as e:
|
||||
self.failed = True
|
||||
# TODO: generic exception wrapper
|
||||
self.exception = f"{type(e).__name__}: {e}"
|
||||
self.exception = format_exception(e)
|
||||
callback = StoredFunc(self.update_status, Success.FAIL)
|
||||
self.thread_man.set_cleanup_func(callback)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user