mirror of
https://github.com/aclist/dztui.git
synced 2026-11-04 17:12:09 +01:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
596d3a59ac |
No files matched your search
+24
-1
@@ -201,19 +201,43 @@ class ServerModelManager:
|
|||||||
|
|
||||||
@call_on_thread(dialog.querying)
|
@call_on_thread(dialog.querying)
|
||||||
def add_by_ip(self, addr: str) -> None:
|
def add_by_ip(self, addr: str) -> None:
|
||||||
|
self.preserve_on_fail = True
|
||||||
|
try:
|
||||||
res = Servers.query_by_ip(addr)
|
res = Servers.query_by_ip(addr)
|
||||||
self._parse_single_record(res)
|
self._parse_single_record(res)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(e)
|
||||||
|
self.thread_man.set_cleanup_func(
|
||||||
|
StoredFunc(self._cleanup_on_failure), destroy_first=True
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
@call_on_thread(dialog.querying)
|
@call_on_thread(dialog.querying)
|
||||||
def add_by_record(self, record: Servers.Record) -> None:
|
def add_by_record(self, record: Servers.Record) -> None:
|
||||||
|
self.preserve_on_fail = True
|
||||||
# NOTE: rationale: a raw Record as shown in server browser may resolve to a different IP
|
# NOTE: rationale: a raw Record as shown in server browser may resolve to a different IP
|
||||||
|
try:
|
||||||
res = Servers.query_by_record(record)
|
res = Servers.query_by_record(record)
|
||||||
self._parse_single_record(res)
|
self._parse_single_record(res)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(e)
|
||||||
|
self.thread_man.set_cleanup_func(
|
||||||
|
StoredFunc(self._cleanup_on_failure), destroy_first=True
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
@call_on_thread(dialog.querying)
|
@call_on_thread(dialog.querying)
|
||||||
def remove_by_record(self, record: Servers.Record) -> None:
|
def remove_by_record(self, record: Servers.Record) -> None:
|
||||||
|
self.preserve_on_fail = True
|
||||||
|
try:
|
||||||
res = Servers.query_by_record(record)
|
res = Servers.query_by_record(record)
|
||||||
self._parse_single_record(res, delete=True)
|
self._parse_single_record(res, delete=True)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(e)
|
||||||
|
self.thread_man.set_cleanup_func(
|
||||||
|
StoredFunc(self._cleanup_on_failure), destroy_first=True
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
def update_history(
|
def update_history(
|
||||||
self,
|
self,
|
||||||
@@ -280,7 +304,6 @@ class ServerModelManager:
|
|||||||
proxy_man.update_playercount(self.playercount)
|
proxy_man.update_playercount(self.playercount)
|
||||||
|
|
||||||
def _parse_single_record(self, response: "A2SInfo", delete: bool = False) -> None:
|
def _parse_single_record(self, response: "A2SInfo", delete: bool = False) -> None:
|
||||||
self.preserve_on_fail = True
|
|
||||||
try:
|
try:
|
||||||
row = response.as_row()
|
row = response.as_row()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ def keys():
|
|||||||
|
|
||||||
# TODO: use a static fixture instead of system config
|
# TODO: use a static fixture instead of system config
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
@pytest.mark.realconfig
|
||||||
def config():
|
def config():
|
||||||
paths = get_xdg_paths()
|
paths = get_xdg_paths()
|
||||||
xdg = parse_filepaths(paths)
|
xdg = parse_filepaths(paths)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import configparser
|
import configparser
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from dzgui.const.constants import FLATPAK_APPID, GTK_APP_ID, TMP_PATH
|
from dzgui.const.constants import FLATPAK_APPID, GTK_APP_ID
|
||||||
from dzgui.config.xdg import get_xdg_paths
|
from dzgui.config.xdg import get_xdg_paths
|
||||||
from dzgui.util.flatpak import apply_overrides
|
from dzgui.util.flatpak import apply_overrides
|
||||||
|
|
||||||
@@ -38,8 +38,6 @@ def test_session_bus(override, config) -> None:
|
|||||||
|
|
||||||
|
|
||||||
def test_paths(override, xdg_paths, config) -> None:
|
def test_paths(override, xdg_paths, config) -> None:
|
||||||
expect: list[str] = []
|
expect = xdg_paths
|
||||||
expect.append(TMP_PATH)
|
|
||||||
expect.extend([*xdg_paths.values()])
|
|
||||||
paths = config[PATHS_KEY][PATHS_SUBKEY].split(";")
|
paths = config[PATHS_KEY][PATHS_SUBKEY].split(";")
|
||||||
assert all(str(path) in paths for path in expect)
|
assert all(str(path) in paths for path in expect.values())
|
||||||
Reference in new issue
Block a user