diff --git a/dzgui/config/xdg.py b/dzgui/config/xdg.py index 1d7f5b3..b72ea7b 100644 --- a/dzgui/config/xdg.py +++ b/dzgui/config/xdg.py @@ -22,7 +22,7 @@ class Xdg: version: Path system: Path debug: Path - ips: Path + db: Path filters: Path shortcut: Path @@ -88,7 +88,7 @@ def parse_filepaths(xdg: dict) -> Xdg: resolution = state / "dzg.res.json" history = state / "dzg.history" versions = state / "dzg.versions" - ips = state / "ips.csv" + db = state / "ips.db" filters = state / "dzg.filters.json" shortcut = share / APP_NAME_LOWER @@ -102,7 +102,7 @@ def parse_filepaths(xdg: dict) -> Xdg: versions, system, debug, - ips, + db, filters, shortcut, ) diff --git a/dzgui/init/coords.py b/dzgui/init/coords.py index 009b386..9381efb 100644 --- a/dzgui/init/coords.py +++ b/dzgui/init/coords.py @@ -10,10 +10,10 @@ if TYPE_CHECKING: logger = logging.getLogger(APP_NAME) -def get_local_coords(path: "Path") -> Coords | None: +def get_local_coords(db_path: "Path") -> Coords | None: try: my_ip = get_local_ip() - return get_coords(path, my_ip) + return get_coords(db_path, my_ip) except Exception as e: logger.warn(e) return None diff --git a/dzgui/util/dist.py b/dzgui/util/dist.py index 0bc6f2b..46c2d44 100644 --- a/dzgui/util/dist.py +++ b/dzgui/util/dist.py @@ -80,8 +80,9 @@ class CalcDist: if local is None: return None try: - remote = get_coords(prefs.paths.ips, remote_ip) - except Exception: + remote = get_coords(prefs.paths.db, remote_ip) + except Exception as e: + logger.critical(e) return None haversine = Haversine(local.lat, local.lon, remote.lat, remote.lon) diff --git a/dzgui/util/ip.py b/dzgui/util/ip.py index 2901986..b6feb24 100644 --- a/dzgui/util/ip.py +++ b/dzgui/util/ip.py @@ -7,6 +7,7 @@ from dataclasses import dataclass from typing import TYPE_CHECKING from dzgui.api.servers import Record +from dzgui.config.ipdb import read_from_table from dzgui.const.constants import REQUEST_TIMEOUT from dzgui.const.endpoints import IP_ECHO diff --git a/dzgui/views/dialogs/boot.py b/dzgui/views/dialogs/boot.py index e16792c..d4aa557 100644 --- a/dzgui/views/dialogs/boot.py +++ b/dzgui/views/dialogs/boot.py @@ -132,9 +132,9 @@ class BootDialog(ColorAwareApp, Gtk.Dialog): # type: ignore preboot.signatures, False, ), - (StoredFunc(get_ipdb, self.xdg.ips), preboot.geo, False), + (StoredFunc(get_ipdb, self.xdg.db), preboot.geo, False), # TODO: handle IP DB failure and use coords fallback - (StoredFunc(get_local_coords, self.xdg.ips), preboot.coords, True), + (StoredFunc(get_local_coords, self.xdg.db), preboot.coords, True), (StoredFunc(check_updates, self.version), preboot.updates, True), ] self.results: list[Any] = []