mirror of
https://github.com/aclist/dztui.git
synced 2026-10-28 05:32:44 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dac02d75f6 | ||
|
|
3a5c061dbf | ||
|
|
3851b76ca0 | ||
|
|
387930b147 | ||
|
|
c0c3ee8c64 | ||
|
|
1212c09110 | ||
|
|
86e2249a23 | ||
|
|
302a43e65e | ||
|
|
3dc58c1a69 | ||
|
|
9af2145ee8 | ||
|
|
7b4382b178 | ||
|
|
ea3631072b | ||
|
|
67bae3c3e0 | ||
|
|
1ea30270ce | ||
|
|
2c9b36ba84 | ||
|
|
fd9eb33714 | ||
|
|
15d928026a | ||
|
|
24d3bc8209 | ||
|
|
881847cee9 | ||
|
|
d3a06cf970 | ||
|
|
741344e75e | ||
|
|
a8a7aba338 | ||
|
|
fafd4c6000 | ||
|
|
7e5e326ebe | ||
|
|
e7644b49f5 | ||
|
|
88aa1c31d5 | ||
|
|
dbeaad73c6 | ||
|
|
be6be2af7c | ||
|
|
63889c2299 | ||
|
|
78e17121b6 | ||
|
|
69ab3723a1 | ||
|
|
c82d42da09 | ||
|
|
9266473853 | ||
|
|
b5d9c030dd | ||
|
|
4852e4a31f | ||
|
|
d56cfdd0b2 | ||
|
|
760208917c | ||
|
|
26006daa74 | ||
|
|
97244e783c | ||
|
|
162839672b | ||
|
|
ac9f582def | ||
|
|
fe40346a01 | ||
|
|
d1cf2a9850 | ||
|
|
4face6f115 |
No files matched your search
@@ -8,7 +8,7 @@ jobs:
|
|||||||
mirror-to-codeberg:
|
mirror-to-codeberg:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: pixta-dev/repository-mirroring-action@v1
|
- uses: pixta-dev/repository-mirroring-action@v1
|
||||||
|
|||||||
+4
-1
@@ -35,6 +35,8 @@
|
|||||||
- Preconnect dialog
|
- Preconnect dialog
|
||||||
- Preconnect warnings/failsafes like filesize
|
- Preconnect warnings/failsafes like filesize
|
||||||
- Save filters per server context between sessions
|
- Save filters per server context between sessions
|
||||||
|
- Preboot progress dialog
|
||||||
|
- Choose to jump into splash screen instead of server
|
||||||
|
|
||||||
|
|
||||||
## Changed
|
## Changed
|
||||||
@@ -50,6 +52,8 @@
|
|||||||
- Suppress log messages from imported modules
|
- Suppress log messages from imported modules
|
||||||
- Embed Workshop link in Options menu
|
- Embed Workshop link in Options menu
|
||||||
- Disable overlay scrollbars on server tables
|
- Disable overlay scrollbars on server tables
|
||||||
|
- Reduce size of geolocation DB on disk (~100MB)
|
||||||
|
- Enable LAN page Empty/Full filters on first run of app
|
||||||
|
|
||||||
## Dropped
|
## Dropped
|
||||||
- Debug mode
|
- Debug mode
|
||||||
@@ -65,7 +69,6 @@
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
- Load offline mods
|
- Load offline mods
|
||||||
- Choose to jump into splash screen instead of server
|
|
||||||
- Local documentation
|
- Local documentation
|
||||||
- Raw debug command in context menu
|
- Raw debug command in context menu
|
||||||
|
|
||||||
|
|||||||
+11
-6
@@ -3,16 +3,21 @@ Knowledge Base
|
|||||||
|
|
||||||
.. _DZG-001:
|
.. _DZG-001:
|
||||||
|
|
||||||
DZG-001: Periodically getting dropped from servers, or servers appear unreachable
|
DZG-001: Periodically getting dropped from servers, or servers time out in DZGUI
|
||||||
------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------
|
||||||
It is a longstanding issue in DayZ that the game opens a large number of connections when querying servers and/or while connected to servers.
|
DayZ opens a large number of connections while querying/connected to servers.
|
||||||
This can result in excess traffic on the user's PC which, depending on how much headroom your network has, can lead to getting dropped, unresponsiveness, or a timeout.
|
|
||||||
|
|
||||||
If you are on Wi-Fi, try switching to a wired connection and see if the problem resolves itself. If it does, your wireless router settings do not have enough headroom for max simultaneous connections. Use a wired connection, or update your network settings to a more permissive setup.
|
In addition, packets sent from server responses are expected to be a standard size (see warning below).
|
||||||
|
|
||||||
Bohemia has acknowledged this issue going back 10+ years and stated that DayZ has a heavy impact on the network, but there is as yet no proposed solution on the DayZ side.
|
If your network does not have enough headroom or has settings departing from defaults, this may lead to getting dropped from servers,
|
||||||
|
unresponsiveness, or a timeout.
|
||||||
|
|
||||||
This issue is frequently seen on Steam Deck, due to the tendency for users to use it in an untethered Wi-Fi setup.
|
If you are on Wi-Fi, try switching to a wired connection and see if the problem resolves itself. Consumer Wi-Fi routers
|
||||||
|
tend to have less headroom than their wired counterparts.
|
||||||
|
|
||||||
|
.. important::
|
||||||
|
Ensure that MTU (maximum tranmission unit) on your network is set to the standard size of 1,500 bytes.
|
||||||
|
If your network preferences or router have "jumbo" frames enabled, packets may be dropped, causing server queries to time out.
|
||||||
|
|
||||||
.. _DZG-002:
|
.. _DZG-002:
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -456,6 +456,5 @@ def get_pretty_version(steam_path: Path, appid: int) -> str | None:
|
|||||||
vers = get_dayz_version(pe_file_path)
|
vers = get_dayz_version(pe_file_path)
|
||||||
dayz_version = dayz_version_to_str(vers)
|
dayz_version = dayz_version_to_str(vers)
|
||||||
return dayz_version
|
return dayz_version
|
||||||
except Exception as e:
|
except Exception:
|
||||||
print(e)
|
|
||||||
return None
|
return None
|
||||||
@@ -61,6 +61,8 @@ class Details:
|
|||||||
|
|
||||||
@dataclass(slots=True)
|
@dataclass(slots=True)
|
||||||
class Record:
|
class Record:
|
||||||
|
# TODO: investigate whether this enum is still being used;
|
||||||
|
# can this be frozen?
|
||||||
"""
|
"""
|
||||||
The gameport field is manipulated by the RowType.CONN_BY_IP method
|
The gameport field is manipulated by the RowType.CONN_BY_IP method
|
||||||
"""
|
"""
|
||||||
@@ -509,6 +511,10 @@ def fqip_to_record(addr: str) -> Optional[Record]:
|
|||||||
return Record(r[0], int(r[1]), int(r[2]))
|
return Record(r[0], int(r[1]), int(r[2]))
|
||||||
|
|
||||||
|
|
||||||
|
def record_to_fqip(record: Record) -> str:
|
||||||
|
return f"{record.ip}:{record.gameport}:{record.qport}"
|
||||||
|
|
||||||
|
|
||||||
def response_to_fqip(res: dict) -> str:
|
def response_to_fqip(res: dict) -> str:
|
||||||
ip = res["addr"].split(":")[0]
|
ip = res["addr"].split(":")[0]
|
||||||
gameport = res["gameport"]
|
gameport = res["gameport"]
|
||||||
|
|||||||
@@ -146,6 +146,23 @@ def connect(client: str, addr: str, appid: int, name: str, mods: list[str]) -> i
|
|||||||
return proc.returncode
|
return proc.returncode
|
||||||
|
|
||||||
|
|
||||||
|
def load_to_menu(client: str, addr: str, appid: int, name: str, mods: list[str]) -> int:
|
||||||
|
"""Loads to the menu screen with the selected mods; used for AFK/pre-joining"""
|
||||||
|
concat = concat_mods(mods)
|
||||||
|
client_args = concat_bash_args(client)
|
||||||
|
params = [
|
||||||
|
"-applaunch",
|
||||||
|
str(appid),
|
||||||
|
"-nolauncher",
|
||||||
|
"-nosplash",
|
||||||
|
"-skipintro",
|
||||||
|
f"-name={name}",
|
||||||
|
f"-mod={concat}",
|
||||||
|
]
|
||||||
|
proc = subprocess.run([*client_args, *params])
|
||||||
|
return proc.returncode
|
||||||
|
|
||||||
|
|
||||||
def find_user_id(path: Path) -> str | None:
|
def find_user_id(path: Path) -> str | None:
|
||||||
resolved_path = path / "config" / "loginusers.vdf"
|
resolved_path = path / "config" / "loginusers.vdf"
|
||||||
try:
|
try:
|
||||||
|
|||||||
+50
-39
@@ -23,40 +23,36 @@ def find_download_url(url: str) -> str | None:
|
|||||||
|
|
||||||
|
|
||||||
def get_ipdb(ips_path: Path) -> None:
|
def get_ipdb(ips_path: Path) -> None:
|
||||||
url = find_download_url(DB_IP)
|
try:
|
||||||
if url is None:
|
url = find_download_url(DB_IP)
|
||||||
return
|
if url is None:
|
||||||
|
|
||||||
date = find_date(url)
|
|
||||||
month_file = ips_path.parent / ".month"
|
|
||||||
if ips_path.exists() and month_file.exists():
|
|
||||||
old_date = month_file.read_text().rstrip("\n")
|
|
||||||
if old_date == date:
|
|
||||||
logger.info(f"IP DB date matches: {date}")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# TODO: log additional output
|
date = find_date(url)
|
||||||
logger.info(f"Fetching IPDB for {date} from {url}")
|
month_file = ips_path.parent / ".month"
|
||||||
try:
|
if ips_path.exists() and month_file.exists():
|
||||||
|
old_date = month_file.read_text().rstrip("\n")
|
||||||
|
if old_date == date:
|
||||||
|
logger.info(f"IP DB date matches: {date}")
|
||||||
|
return
|
||||||
|
|
||||||
|
# TODO: log additional output
|
||||||
|
logger.info(f"Fetching IPDB for {date} from {url}")
|
||||||
tmp = serialize(url)
|
tmp = serialize(url)
|
||||||
except Exception as e:
|
logger.info(f"Extracting {tmp}")
|
||||||
logger.critical(e)
|
unzip(tmp, ips_path)
|
||||||
return
|
|
||||||
|
|
||||||
logger.info(f"Extracting {tmp}")
|
logger.info("Stripping IPv6 records")
|
||||||
unzip(tmp, ips_path)
|
|
||||||
|
|
||||||
logger.info("Stripping IPv6 records")
|
|
||||||
try:
|
|
||||||
strip_ipv6(ips_path)
|
strip_ipv6(ips_path)
|
||||||
|
|
||||||
|
with open(month_file, "w") as f:
|
||||||
|
f.write(date)
|
||||||
|
logger.info(f"Wrote {date} to {month_file}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
# NOTE: in the event of failure, geolocation calc is simply not performed
|
||||||
logger.critical(e)
|
logger.critical(e)
|
||||||
return
|
return
|
||||||
|
|
||||||
with open(month_file, "w") as f:
|
|
||||||
f.write(date)
|
|
||||||
logger.info(f"Wrote {date} to {month_file}")
|
|
||||||
|
|
||||||
|
|
||||||
def find_date(url: str) -> str:
|
def find_date(url: str) -> str:
|
||||||
date = re.sub(r"(dbip-city-lite-)(.*)(.csv.gz)", r"\2", url)
|
date = re.sub(r"(dbip-city-lite-)(.*)(.csv.gz)", r"\2", url)
|
||||||
@@ -81,19 +77,34 @@ def serialize(url: str) -> Path:
|
|||||||
return tmp
|
return tmp
|
||||||
|
|
||||||
|
|
||||||
# TODO: optimize this function
|
|
||||||
# consider using grep
|
|
||||||
# cf. grep -vE "^[a-z0-9]{4}:" | grep -v "::" > "$ip_file"
|
|
||||||
def strip_ipv6(path: Path) -> None:
|
def strip_ipv6(path: Path) -> None:
|
||||||
ips = []
|
"""Can be IO intensive and cause visual lag on UI frames
|
||||||
with open(path, "r") as f:
|
running in the main thread even when run in its own thread;
|
||||||
s = f.read()
|
lines are batched into memory-manageable chunks to reduce
|
||||||
|
disk writes. Raw file can be 8M+ records long, so it is
|
||||||
|
not read into memory at once.
|
||||||
|
|
||||||
reg = r"^\d{1,3}\..*"
|
Relative size is reduced by ~100MB by pruning unwanted columns
|
||||||
ips = re.findall(reg, s, re.MULTILINE)
|
"""
|
||||||
assert ips[0].split(",")[0] == "0.0.0.0"
|
# NOTE: "^::," is the boundary line between IPv4 and IPv6
|
||||||
assert ips[-1].split(",")[0] == "224.0.0.0"
|
# NOTE: deprecated regex matching (slower by 5s)
|
||||||
|
# reg = r"^\d{1,3}\..*"
|
||||||
with open(path, "w") as f:
|
alt_path = path.parent.joinpath("ips_stripped.csv")
|
||||||
for ip in ips:
|
merged = ""
|
||||||
f.write(ip + "\n")
|
its = 0
|
||||||
|
with open(path, "r") as f, open(alt_path, "w") as out:
|
||||||
|
for line in f:
|
||||||
|
els = line.split(",")
|
||||||
|
if "." not in els[0]:
|
||||||
|
break
|
||||||
|
final = ",".join([els[0], els[1], els[-2], els[-1]])
|
||||||
|
merged += final
|
||||||
|
its += 1
|
||||||
|
if its == 500:
|
||||||
|
out.write(merged)
|
||||||
|
its = 0
|
||||||
|
merged = ""
|
||||||
|
if its > 0:
|
||||||
|
out.write(merged)
|
||||||
|
path.unlink()
|
||||||
|
alt_path.rename(path)
|
||||||
@@ -28,6 +28,7 @@ APP_NAME = "DZGUI"
|
|||||||
APP_NAME_LOWER = "dzgui"
|
APP_NAME_LOWER = "dzgui"
|
||||||
APP_NAME_ABBR = "dzg"
|
APP_NAME_ABBR = "dzg"
|
||||||
|
|
||||||
|
HEX_GREEN = "#32CD32"
|
||||||
HEX_RED = "#FF0000"
|
HEX_RED = "#FF0000"
|
||||||
HEX_ORANGE = "#FFAC1C"
|
HEX_ORANGE = "#FFAC1C"
|
||||||
|
|
||||||
|
|||||||
@@ -409,9 +409,12 @@ class Controller(GObject.GObject):
|
|||||||
saved_tree = self.get_servers().get_saved()
|
saved_tree = self.get_servers().get_saved()
|
||||||
ServerModelManager(self, saved_tree).remove_by_record(record)
|
ServerModelManager(self, saved_tree).remove_by_record(record)
|
||||||
|
|
||||||
def add_to_history(self, record: dict[str, Any]) -> None:
|
def add_to_history(self, row: dict[str, Any], record: "Record") -> None:
|
||||||
tv = self.get_servers().get_recent()
|
tv = self.get_servers().get_recent()
|
||||||
ServerModelManager(self, tv).add_to_history(record)
|
ServerModelManager(self, tv).add_to_history((row, record))
|
||||||
|
|
||||||
|
# def append_to_history(self, record: "Record") -> None:
|
||||||
|
# self.config_man.append_to_history_file(record)
|
||||||
|
|
||||||
def remove_from_history(self, record: "Record") -> None:
|
def remove_from_history(self, record: "Record") -> None:
|
||||||
# NOTE: remove action is only possible from history tree context menu,
|
# NOTE: remove action is only possible from history tree context menu,
|
||||||
@@ -508,6 +511,9 @@ class Controller(GObject.GObject):
|
|||||||
ind = self.config_man.get_start_tab()
|
ind = self.config_man.get_start_tab()
|
||||||
self.get_servers().notebook.set_current_page(ind)
|
self.get_servers().notebook.set_current_page(ind)
|
||||||
|
|
||||||
|
def update_and_load_to_menu(self, raise_window: bool) -> None:
|
||||||
|
self.connection_man.update_and_connect(raise_window, menu_only=True)
|
||||||
|
|
||||||
def update_and_connect(self, raise_window: bool) -> None:
|
def update_and_connect(self, raise_window: bool) -> None:
|
||||||
self.connection_man.update_and_connect(raise_window)
|
self.connection_man.update_and_connect(raise_window)
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,8 @@
|
|||||||
- Preconnect dialog
|
- Preconnect dialog
|
||||||
- Preconnect warnings/failsafes like filesize
|
- Preconnect warnings/failsafes like filesize
|
||||||
- Save filters per server context between sessions
|
- Save filters per server context between sessions
|
||||||
|
- Preboot progress dialog
|
||||||
|
- Choose to jump into splash screen instead of server
|
||||||
|
|
||||||
|
|
||||||
## Changed
|
## Changed
|
||||||
@@ -50,6 +52,8 @@
|
|||||||
- Suppress log messages from imported modules
|
- Suppress log messages from imported modules
|
||||||
- Embed Workshop link in Options menu
|
- Embed Workshop link in Options menu
|
||||||
- Disable overlay scrollbars on server tables
|
- Disable overlay scrollbars on server tables
|
||||||
|
- Reduce size of geolocation DB on disk (~100MB)
|
||||||
|
- Enable LAN page Empty/Full filters on first run of app
|
||||||
|
|
||||||
## Dropped
|
## Dropped
|
||||||
- Debug mode
|
- Debug mode
|
||||||
@@ -65,7 +69,6 @@
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
- Load offline mods
|
- Load offline mods
|
||||||
- Choose to jump into splash screen instead of server
|
|
||||||
- Local documentation
|
- Local documentation
|
||||||
- Raw debug command in context menu
|
- Raw debug command in context menu
|
||||||
|
|
||||||
|
|||||||
@@ -13,11 +13,6 @@ logger = logging.getLogger(APP_NAME)
|
|||||||
def get_local_coords(path: "Path") -> Coords | None:
|
def get_local_coords(path: "Path") -> Coords | None:
|
||||||
try:
|
try:
|
||||||
my_ip = get_local_ip()
|
my_ip = get_local_ip()
|
||||||
except Exception as e:
|
|
||||||
logger.warn(e)
|
|
||||||
return None
|
|
||||||
|
|
||||||
try:
|
|
||||||
return get_coords(path, my_ip)
|
return get_coords(path, my_ip)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warn(e)
|
logger.warn(e)
|
||||||
|
|||||||
+11
-18
@@ -6,14 +6,11 @@ import warnings
|
|||||||
|
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from dzgui.api.mods import remove_stale_signatures
|
|
||||||
from dzgui.const.constants import APP_NAME
|
from dzgui.const.constants import APP_NAME
|
||||||
from dzgui.const.enum import Preferences
|
from dzgui.const.enum import Preferences
|
||||||
from dzgui.config.ipdb import get_ipdb
|
|
||||||
from dzgui.config.query import lookup
|
from dzgui.config.query import lookup
|
||||||
from dzgui.config.userprefs import UserPrefs
|
from dzgui.config.userprefs import UserPrefs
|
||||||
from dzgui.config.xdg import get_xdg_paths, parse_filepaths
|
from dzgui.config.xdg import get_xdg_paths, parse_filepaths
|
||||||
from dzgui.init.coords import get_local_coords
|
|
||||||
from dzgui.init.dayz import is_dayz_installed
|
from dzgui.init.dayz import is_dayz_installed
|
||||||
from dzgui.init.flock import lock_acquire
|
from dzgui.init.flock import lock_acquire
|
||||||
from dzgui.init.migrate import (
|
from dzgui.init.migrate import (
|
||||||
@@ -24,17 +21,16 @@ from dzgui.init.migrate import (
|
|||||||
from dzgui.init.prefix import get_version
|
from dzgui.init.prefix import get_version
|
||||||
from dzgui.init.prereqs import has_steam_client
|
from dzgui.init.prereqs import has_steam_client
|
||||||
from dzgui.strings import boot
|
from dzgui.strings import boot
|
||||||
from dzgui.init.update import check_updates
|
|
||||||
|
|
||||||
# from dzgui.util.map_count import get_map_count
|
# from dzgui.util.map_count import get_map_count
|
||||||
from dzgui.util.deck import is_steam_deck, is_game_mode
|
from dzgui.util.deck import is_steam_deck, is_game_mode
|
||||||
from dzgui.util.localize import set_locale
|
from dzgui.util.localize import set_locale
|
||||||
from dzgui.util.symlink import rebuild_symlinks
|
|
||||||
from dzgui.util.strings import init, flags
|
from dzgui.util.strings import init, flags
|
||||||
|
|
||||||
from dzgui.views.base import App
|
from dzgui.views.base import App
|
||||||
from dzgui.views.dialogs.wizard import SetupWizard
|
from dzgui.views.dialogs.boot import BootWindow
|
||||||
from dzgui.views.dialogs.early_alert import EarlyAlertDialog
|
from dzgui.views.dialogs.early_alert import EarlyAlertDialog
|
||||||
|
from dzgui.views.dialogs.wizard import SetupWizard
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -130,20 +126,17 @@ def main() -> None:
|
|||||||
|
|
||||||
is_dayz_installed(XDG.config)
|
is_dayz_installed(XDG.config)
|
||||||
|
|
||||||
# TODO: slow running procs here--needs dialog
|
bootwin = BootWindow(XDG, version)
|
||||||
# NOTE: clears versions file of unlinked mods
|
local_coords, latest_release = bootwin.get_results()
|
||||||
rebuild_symlinks(XDG.config)
|
|
||||||
remove_stale_signatures(XDG.config, XDG.version)
|
# rebuild_symlinks(XDG.config)
|
||||||
|
# remove_stale_signatures(XDG.config, XDG.version)
|
||||||
|
|
||||||
|
## TODO: handle IP DB failure and use coords fallback
|
||||||
|
# local_coords = get_local_coords(XDG.ips)
|
||||||
|
# latest_release = check_updates(version)
|
||||||
|
|
||||||
# TODO: handle IP DB failure and use coords fallback
|
|
||||||
# TODO: drop this after dialog is complete
|
|
||||||
print("Fetching geolocation data, may take some time...")
|
|
||||||
get_ipdb(XDG.ips)
|
|
||||||
local_coords = get_local_coords(XDG.ips)
|
|
||||||
use_miles = lookup(XDG.config, Preferences.DIST)
|
use_miles = lookup(XDG.config, Preferences.DIST)
|
||||||
|
|
||||||
latest_release = check_updates(version)
|
|
||||||
|
|
||||||
prefs = UserPrefs(
|
prefs = UserPrefs(
|
||||||
is_steam_deck=_is_steam_deck,
|
is_steam_deck=_is_steam_deck,
|
||||||
is_game_mode=_is_game_mode,
|
is_game_mode=_is_game_mode,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
|
from collections import deque
|
||||||
from typing import Any, TYPE_CHECKING
|
from typing import Any, TYPE_CHECKING
|
||||||
|
|
||||||
from dzgui.const.constants import (
|
from dzgui.const.constants import (
|
||||||
@@ -52,11 +53,25 @@ class ConfigManager:
|
|||||||
ips.append(record)
|
ips.append(record)
|
||||||
self.update_config(Preferences.IP_LIST, ips)
|
self.update_config(Preferences.IP_LIST, ips)
|
||||||
|
|
||||||
def update_history_file(self, records: list[Any]) -> None:
|
def update_history_file(self, fqip: str) -> None:
|
||||||
|
with open(self.prefs.paths.history, "r") as f:
|
||||||
|
ips = [line.rstrip() for line in f.readlines()]
|
||||||
|
|
||||||
|
seen = set()
|
||||||
|
ips.append(fqip)
|
||||||
|
# NOTE: Preserve linear order of records while deduplicating
|
||||||
|
unique = deque(maxlen=10) # type: ignore
|
||||||
|
for i in range(len(ips) - 1, -1, -1):
|
||||||
|
if ips[i] not in seen:
|
||||||
|
seen.add(ips[i])
|
||||||
|
unique.appendleft(ips[i])
|
||||||
|
# NOTE: appendleft will push 11th item off right edge
|
||||||
|
if len(unique) == 10:
|
||||||
|
break
|
||||||
|
|
||||||
with open(self.prefs.paths.history, "w") as f:
|
with open(self.prefs.paths.history, "w") as f:
|
||||||
for record in records:
|
for record in unique:
|
||||||
addr = f"{record[7]}:{record[8]}"
|
f.write(f"{record}\n")
|
||||||
f.write(f"{addr}\n")
|
|
||||||
|
|
||||||
def remove_saved_server(self, record: str) -> None:
|
def remove_saved_server(self, record: str) -> None:
|
||||||
ips = self.lookup(Preferences.IP_LIST)
|
ips = self.lookup(Preferences.IP_LIST)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ from dzgui.api.steam import (
|
|||||||
enqueue_mod,
|
enqueue_mod,
|
||||||
get_remote_signatures,
|
get_remote_signatures,
|
||||||
get_needs_update,
|
get_needs_update,
|
||||||
|
load_to_menu,
|
||||||
)
|
)
|
||||||
|
|
||||||
from dzgui.api.mods import (
|
from dzgui.api.mods import (
|
||||||
@@ -74,6 +75,7 @@ class Prerequisites:
|
|||||||
steam_proc: SteamProcess
|
steam_proc: SteamProcess
|
||||||
mods: list[list[str]]
|
mods: list[list[str]]
|
||||||
game_mode: bool
|
game_mode: bool
|
||||||
|
is_last_server: bool
|
||||||
|
|
||||||
|
|
||||||
class ConnectionManager:
|
class ConnectionManager:
|
||||||
@@ -172,6 +174,8 @@ class ConnectionManager:
|
|||||||
|
|
||||||
game_mode = prefs.is_game_mode
|
game_mode = prefs.is_game_mode
|
||||||
|
|
||||||
|
is_last = self.is_last_server()
|
||||||
|
|
||||||
prereqs = Prerequisites(
|
prereqs = Prerequisites(
|
||||||
name=info.server_name,
|
name=info.server_name,
|
||||||
appid=info.game_id,
|
appid=info.game_id,
|
||||||
@@ -186,11 +190,23 @@ class ConnectionManager:
|
|||||||
steam_proc=steam_proc,
|
steam_proc=steam_proc,
|
||||||
mods=remote_mods,
|
mods=remote_mods,
|
||||||
game_mode=game_mode,
|
game_mode=game_mode,
|
||||||
|
is_last_server=is_last,
|
||||||
)
|
)
|
||||||
|
|
||||||
func = StoredFunc(self.controller.open_connection_assistant, prereqs)
|
func = StoredFunc(self.controller.open_connection_assistant, prereqs)
|
||||||
self.thread_man.set_cleanup_func(func, destroy_first=True)
|
self.thread_man.set_cleanup_func(func, destroy_first=True)
|
||||||
|
|
||||||
|
def is_last_server(self) -> bool:
|
||||||
|
prefs = self.controller.get_prefs()
|
||||||
|
history = prefs.paths.history
|
||||||
|
try:
|
||||||
|
lines = history.read_text().splitlines()
|
||||||
|
last = lines[-1]
|
||||||
|
current = Servers.record_to_fqip(self.record)
|
||||||
|
return last == current
|
||||||
|
except Exception:
|
||||||
|
return False
|
||||||
|
|
||||||
@call_on_thread(dialog.querying)
|
@call_on_thread(dialog.querying)
|
||||||
def query_details(self, record: Servers.Record) -> None:
|
def query_details(self, record: Servers.Record) -> None:
|
||||||
details = Servers.get_details(record)
|
details = Servers.get_details(record)
|
||||||
@@ -245,11 +261,14 @@ class ConnectionManager:
|
|||||||
dialog = ExceptionDialog(self.controller, server_timeout)
|
dialog = ExceptionDialog(self.controller, server_timeout)
|
||||||
dialog.run()
|
dialog.run()
|
||||||
|
|
||||||
def _connect_steam(self) -> None:
|
def _connect_steam(self, menu_only: bool) -> None:
|
||||||
addr = f"{self.record.ip}:{self.record.gameport}"
|
addr = f"{self.record.ip}:{self.record.gameport}"
|
||||||
playername = self.controller.query_config(Preferences.NAME)
|
playername = self.controller.query_config(Preferences.NAME)
|
||||||
client = self.controller.query_config(Preferences.CLIENT)
|
client = self.controller.query_config(Preferences.CLIENT)
|
||||||
rc = connect(client, addr, self.appid, playername, self.remote_mod_ids)
|
if menu_only:
|
||||||
|
rc = load_to_menu(client, addr, self.appid, playername, self.remote_mod_ids)
|
||||||
|
else:
|
||||||
|
rc = connect(client, addr, self.appid, playername, self.remote_mod_ids)
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
# TODO: log/pop the error
|
# TODO: log/pop the error
|
||||||
func = StoredFunc(self.controller.update_status)
|
func = StoredFunc(self.controller.update_status)
|
||||||
@@ -271,10 +290,10 @@ class ConnectionManager:
|
|||||||
self.thread_man.set_cleanup_func(func)
|
self.thread_man.set_cleanup_func(func)
|
||||||
|
|
||||||
def _add_to_history_and_return(self) -> None:
|
def _add_to_history_and_return(self) -> None:
|
||||||
self.controller.add_to_history(self.history)
|
self.controller.add_to_history(self.history, self.record)
|
||||||
self.controller.open_page(NotebookPage.SERVERS)
|
self.controller.open_page(NotebookPage.SERVERS)
|
||||||
|
|
||||||
def _update_mods(self, raise_window: bool) -> None:
|
def _update_mods(self, raise_window: bool, menu_only: bool = False) -> None:
|
||||||
# NOTE: fast enqueue all mods in auto mode
|
# NOTE: fast enqueue all mods in auto mode
|
||||||
prefs = self.controller.get_prefs()
|
prefs = self.controller.get_prefs()
|
||||||
|
|
||||||
@@ -312,11 +331,11 @@ class ConnectionManager:
|
|||||||
update_signatures(self.missing_mods, prefs.paths.version)
|
update_signatures(self.missing_mods, prefs.paths.version)
|
||||||
# TODO: just push steam path directly
|
# TODO: just push steam path directly
|
||||||
rebuild_symlinks(prefs.paths.config)
|
rebuild_symlinks(prefs.paths.config)
|
||||||
self._connect_steam()
|
self._connect_steam(menu_only)
|
||||||
|
|
||||||
@call_on_thread(waiting_for_mods, show_cancel=True)
|
@call_on_thread(waiting_for_mods, show_cancel=True)
|
||||||
def update_and_connect(self, raise_window: bool) -> None:
|
def update_and_connect(self, raise_window: bool, menu_only: bool = False) -> None:
|
||||||
if len(self.missing_mods) > 0:
|
if len(self.missing_mods) > 0:
|
||||||
self._update_mods(raise_window)
|
self._update_mods(raise_window, menu_only)
|
||||||
else:
|
else:
|
||||||
self._connect_steam()
|
self._connect_steam(menu_only)
|
||||||
@@ -9,7 +9,7 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
|
|
||||||
class FilterManager:
|
class FilterManager:
|
||||||
def __init__(self) -> None:
|
def __init__(self, show_empty: bool = False, show_full: bool = False) -> None:
|
||||||
|
|
||||||
self.map_store = ModelFactory().make_map_store()
|
self.map_store = ModelFactory().make_map_store()
|
||||||
|
|
||||||
@@ -17,10 +17,10 @@ class FilterManager:
|
|||||||
self.default_filters = {
|
self.default_filters = {
|
||||||
strings.filter_1pp: True,
|
strings.filter_1pp: True,
|
||||||
strings.filter_day: True,
|
strings.filter_day: True,
|
||||||
strings.filter_empty: False,
|
strings.filter_empty: show_empty,
|
||||||
strings.filter_3pp: True,
|
strings.filter_3pp: True,
|
||||||
strings.filter_night: True,
|
strings.filter_night: True,
|
||||||
strings.filter_full: False,
|
strings.filter_full: show_full,
|
||||||
strings.filter_lowpop: True,
|
strings.filter_lowpop: True,
|
||||||
strings.filter_nonascii: False,
|
strings.filter_nonascii: False,
|
||||||
strings.filter_duplicate: False,
|
strings.filter_duplicate: False,
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ class StoredFunc:
|
|||||||
self.func = func
|
self.func = func
|
||||||
self.bindings = sig.bind(*args, **kwargs)
|
self.bindings = sig.bind(*args, **kwargs)
|
||||||
|
|
||||||
def call(self) -> None:
|
def call(self) -> Any:
|
||||||
self.func(*self.bindings.args, *self.bindings.kwargs)
|
return self.func(*self.bindings.args, *self.bindings.kwargs)
|
||||||
|
|
||||||
|
|
||||||
class ThreadingManager:
|
class ThreadingManager:
|
||||||
@@ -113,8 +113,8 @@ class ThreadingManager:
|
|||||||
|
|
||||||
func = self.get_cleanup_func()
|
func = self.get_cleanup_func()
|
||||||
if func is not None:
|
if func is not None:
|
||||||
func.call()
|
|
||||||
self.set_cleanup_func(None)
|
self.set_cleanup_func(None)
|
||||||
|
func.call()
|
||||||
if not self.destroy_first:
|
if not self.destroy_first:
|
||||||
self.destroy_dialog()
|
self.destroy_dialog()
|
||||||
|
|
||||||
|
|||||||
@@ -85,8 +85,9 @@ class ProxyModelManager:
|
|||||||
|
|
||||||
if found is False:
|
if found is False:
|
||||||
self.control_model.append(history)
|
self.control_model.append(history)
|
||||||
if len(self.control_model) == 11:
|
|
||||||
del self.control_model[0]
|
# if len(self.control_model) == 11:
|
||||||
|
# del self.control_model[0]
|
||||||
|
|
||||||
self.filter(FilterMode.INITIAL, skip_cache=True)
|
self.filter(FilterMode.INITIAL, skip_cache=True)
|
||||||
|
|
||||||
|
|||||||
+22
-9
@@ -14,6 +14,7 @@ from dzgui.const.constants import (
|
|||||||
)
|
)
|
||||||
from dzgui.const.enum import FilterMode, Preferences, ServerTab
|
from dzgui.const.enum import FilterMode, Preferences, ServerTab
|
||||||
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
|
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
|
||||||
|
from dzgui.strings import dialogs
|
||||||
from dzgui.util.strings import api_warn_msg, dialog
|
from dzgui.util.strings import api_warn_msg, dialog
|
||||||
from dzgui.views.dialogs.generic import ExceptionDialog
|
from dzgui.views.dialogs.generic import ExceptionDialog
|
||||||
|
|
||||||
@@ -23,7 +24,7 @@ gi.require_version("Gtk", "3.0")
|
|||||||
from gi.repository import Gtk # noqa E402
|
from gi.repository import Gtk # noqa E402
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from dzgui.api.servers import A2SInfo
|
from dzgui.api.servers import A2SInfo, Record
|
||||||
from dzgui.controllers.mc import Controller
|
from dzgui.controllers.mc import Controller
|
||||||
from dzgui.model.proxy_model import ProxyModelManager
|
from dzgui.model.proxy_model import ProxyModelManager
|
||||||
from dzgui.views.trees.tree_servers import ServerTreeView
|
from dzgui.views.trees.tree_servers import ServerTreeView
|
||||||
@@ -130,7 +131,7 @@ class ServerModelManager:
|
|||||||
|
|
||||||
servers = []
|
servers = []
|
||||||
ports = range(1, 256)
|
ports = range(1, 256)
|
||||||
failure_func = StoredFunc(self._cleanup_on_failure)
|
failure_func = StoredFunc(self._cleanup_on_lan_failure)
|
||||||
|
|
||||||
event = threading.Event()
|
event = threading.Event()
|
||||||
with ThreadPoolExecutor() as executor:
|
with ThreadPoolExecutor() as executor:
|
||||||
@@ -225,15 +226,12 @@ class ServerModelManager:
|
|||||||
) = None,
|
) = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
proxy_man = self._get_proxy_man()
|
proxy_man = self._get_proxy_man()
|
||||||
config_man = self.controller.get_config_man()
|
|
||||||
if rows is not None:
|
if rows is not None:
|
||||||
records = rows
|
records = rows
|
||||||
else:
|
else:
|
||||||
control_model = proxy_man.get_control()
|
control_model = proxy_man.get_control()
|
||||||
records = control_model
|
records = control_model
|
||||||
|
|
||||||
config_man.update_history_file(records)
|
|
||||||
config_man.update_history_file(records)
|
|
||||||
self._sort_unique_maps(records)
|
self._sort_unique_maps(records)
|
||||||
proxy = proxy_man.get_proxy_model()
|
proxy = proxy_man.get_proxy_model()
|
||||||
self.tv.set_model(proxy)
|
self.tv.set_model(proxy)
|
||||||
@@ -249,15 +247,20 @@ class ServerModelManager:
|
|||||||
self.emitter.emit("load_maps", store)
|
self.emitter.emit("load_maps", store)
|
||||||
# self.emitter.emit("servers_loaded_init")
|
# self.emitter.emit("servers_loaded_init")
|
||||||
|
|
||||||
def add_to_history(self, record: dict[str, Any]) -> None:
|
# TODO: dataclass for record rows; check for other dict annotations
|
||||||
|
def add_to_history(self, data: tuple[dict[str, Any], "Record"]) -> None:
|
||||||
|
row, record = data
|
||||||
proxy_man = self._get_proxy_man()
|
proxy_man = self._get_proxy_man()
|
||||||
rows = Servers.parse_json([record])
|
rows = Servers.parse_json([row])
|
||||||
try:
|
try:
|
||||||
proxy_man.append_row_to_history(rows[0])
|
proxy_man.append_row_to_history(rows[0])
|
||||||
|
self.update_history()
|
||||||
except Exception:
|
except Exception:
|
||||||
self.update_history(rows)
|
self.update_history(rows)
|
||||||
return
|
|
||||||
self.update_history()
|
fqip = Servers.record_to_fqip(record)
|
||||||
|
config_man = self.controller.get_config_man()
|
||||||
|
config_man.update_history_file(fqip)
|
||||||
|
|
||||||
def remove_from_history(self, record: Servers.Record) -> None:
|
def remove_from_history(self, record: Servers.Record) -> None:
|
||||||
proxy_man = self._get_proxy_man()
|
proxy_man = self._get_proxy_man()
|
||||||
@@ -403,6 +406,16 @@ class ServerModelManager:
|
|||||||
if self.first_iteration:
|
if self.first_iteration:
|
||||||
self._update_maps()
|
self._update_maps()
|
||||||
|
|
||||||
|
def _cleanup_on_lan_failure(self, show_dialog: bool = True) -> None:
|
||||||
|
if self.preserve_on_fail is False:
|
||||||
|
self.tv.set_model(None)
|
||||||
|
filter_man = self.tv.get_filter_man()
|
||||||
|
filter_man.set_unique_maps([])
|
||||||
|
|
||||||
|
if show_dialog:
|
||||||
|
dialog = ExceptionDialog(self.controller, dialogs.load_error_lan)
|
||||||
|
dialog.run()
|
||||||
|
|
||||||
def _cleanup_on_failure(self, show_dialog: bool = True) -> None:
|
def _cleanup_on_failure(self, show_dialog: bool = True) -> None:
|
||||||
# TODO: disable map, keyword, and filter widgets if model is None
|
# TODO: disable map, keyword, and filter widgets if model is None
|
||||||
# signal driven (servers_empty, servers_failed_to_load)
|
# signal driven (servers_empty, servers_failed_to_load)
|
||||||
|
|||||||
@@ -4,3 +4,5 @@ waiting_for_mods = "Waiting for Steam to update mods"
|
|||||||
fetching_update = "Fetching update"
|
fetching_update = "Fetching update"
|
||||||
failed_to_update = "Failed to update DZGUI executable"
|
failed_to_update = "Failed to update DZGUI executable"
|
||||||
update_success = "Updated successfully. Please exit and relaunch."
|
update_success = "Updated successfully. Please exit and relaunch."
|
||||||
|
|
||||||
|
load_error_lan = "Failed to find any servers on your network.\nCheck the server query port or your firewall settings."
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
symlinks = "Rebuilding symlinks"
|
||||||
|
signatures = "Updating mod signatures"
|
||||||
|
geo = "Checking geolocation records"
|
||||||
|
coords = "Checking local coordinates"
|
||||||
|
updates = "Checking for updates"
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
update_mods = "Update mods and connect"
|
update_mods = "Update mods and connect"
|
||||||
connect = "Connect"
|
connect = "Connect"
|
||||||
|
connect_last = "Load to menu screen"
|
||||||
|
connect_last_tooltip = (
|
||||||
|
"Launch DayZ with these mods (if any) and\ngo to the menu screen without connecting."
|
||||||
|
)
|
||||||
back = "Back"
|
back = "Back"
|
||||||
cancel = "Cancel"
|
cancel = "Cancel"
|
||||||
warnings = "Warnings"
|
warnings = "Warnings"
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ def read_json(path: Path) -> Any:
|
|||||||
|
|
||||||
def write_json(data: dict[str, Any], path: Path) -> None:
|
def write_json(data: dict[str, Any], path: Path) -> None:
|
||||||
try:
|
try:
|
||||||
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
j = json.dumps(data, indent=2)
|
j = json.dumps(data, indent=2)
|
||||||
path.write_text(j)
|
path.write_text(j)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
def is_writeable(path: "Path") -> bool:
|
||||||
|
now = int(datetime.now().timestamp())
|
||||||
|
suffix = ".dzgtmp"
|
||||||
|
file = str(now) + suffix
|
||||||
|
filepath = Path(str(path) + "_" + file)
|
||||||
|
try:
|
||||||
|
filepath.touch()
|
||||||
|
filepath.unlink()
|
||||||
|
return True
|
||||||
|
except OSError:
|
||||||
|
return False
|
||||||
@@ -360,12 +360,14 @@ thanks = Thanks(
|
|||||||
"bongjutsu",
|
"bongjutsu",
|
||||||
"Deku",
|
"Deku",
|
||||||
"dj3hac",
|
"dj3hac",
|
||||||
|
"finntux",
|
||||||
"GaryBlackbourne",
|
"GaryBlackbourne",
|
||||||
"jiriks74",
|
"jiriks74",
|
||||||
"Johnofwrong",
|
"Johnofwrong",
|
||||||
"MatheusLasserr",
|
"MatheusLasserr",
|
||||||
"nolan-perez",
|
"nolan-perez",
|
||||||
"scandalouss",
|
"scandalouss",
|
||||||
|
"SnackSBR",
|
||||||
"StevelDusa",
|
"StevelDusa",
|
||||||
"Thoughtduck216",
|
"Thoughtduck216",
|
||||||
],
|
],
|
||||||
@@ -609,6 +611,7 @@ atomic_buttons = AtomicButton(
|
|||||||
keys_tooltip="Toggles the keybindings dialog",
|
keys_tooltip="Toggles the keybindings dialog",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
gtk_theme_missing = "No GTK theme provided"
|
||||||
steam_icon_missing = "Steam icon not found in IconTheme"
|
steam_icon_missing = "Steam icon not found in IconTheme"
|
||||||
|
|
||||||
missing_changelog = "Error: failed to read changelog"
|
missing_changelog = "Error: failed to read changelog"
|
||||||
|
|||||||
+9
-5
@@ -323,8 +323,12 @@ class App(Gtk.Application):
|
|||||||
|
|
||||||
MainController = Controller()
|
MainController = Controller()
|
||||||
|
|
||||||
theme = Gtk.IconTheme.get_default()
|
try:
|
||||||
icons = theme.list_icons(None)
|
theme = Gtk.IconTheme.get_default()
|
||||||
if STEAM_ICON not in icons:
|
icons = theme.list_icons(None)
|
||||||
logger.warn(strings.steam_icon_missing)
|
if STEAM_ICON not in icons:
|
||||||
warnings.warn(strings.steam_icon_missing, stacklevel=2)
|
logger.warn(strings.steam_icon_missing)
|
||||||
|
warnings.warn(strings.steam_icon_missing, stacklevel=2)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(e)
|
||||||
|
warnings.warn(strings.gtk_theme_missing, stacklevel=2)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Callable, Self, TYPE_CHECKING
|
from typing import Callable, Self, TYPE_CHECKING, Union
|
||||||
|
|
||||||
from dzgui.util.clip import copy_clipboard
|
from dzgui.util.clip import copy_clipboard
|
||||||
from dzgui.util.format import pluralize
|
from dzgui.util.format import pluralize
|
||||||
@@ -70,18 +70,26 @@ class LargeIconTextButton(IconButton):
|
|||||||
|
|
||||||
|
|
||||||
class ClipboardButton(IconTextButton):
|
class ClipboardButton(IconTextButton):
|
||||||
def __init__(self, controller: "Controller", func: Callable) -> None:
|
def __init__(self, controller: Union["Controller", None], func: Callable) -> None:
|
||||||
super().__init__(CLIPBOARD, atomic_buttons.copy)
|
super().__init__(CLIPBOARD, atomic_buttons.copy)
|
||||||
self.controller = controller
|
self.controller = controller
|
||||||
self.connect("clicked", self._on_button_clicked, func)
|
self.connect("clicked", self._on_button_clicked, func)
|
||||||
|
|
||||||
self.set_tooltip_text("Copy IP to clipboard")
|
self.set_tooltip_text("Copy to clipboard")
|
||||||
|
|
||||||
def _on_button_clicked(self, button: Self, func: Callable) -> None:
|
def _on_button_clicked(self, button: Self, func: Callable) -> None:
|
||||||
data = func()
|
data = func()
|
||||||
copy_clipboard(data)
|
copy_clipboard(data)
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: determine when controller would be passed to this button or drop
|
||||||
|
class CopyIpButton(ClipboardButton):
|
||||||
|
def __init__(self, controller: Union["Controller", None], func: Callable) -> None:
|
||||||
|
super().__init__(controller, func)
|
||||||
|
|
||||||
|
self.set_tooltip_text("Copy IP to clipboard")
|
||||||
|
|
||||||
|
|
||||||
class WebButton(IconTextButton):
|
class WebButton(IconTextButton):
|
||||||
def __init__(self, label: str) -> None:
|
def __init__(self, label: str) -> None:
|
||||||
super().__init__(icon=WEB_BROWSER, label=label)
|
super().__init__(icon=WEB_BROWSER, label=label)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from dzgui.strings import connect_panel
|
|||||||
from dzgui.util.keys import is_ctrl_mask
|
from dzgui.util.keys import is_ctrl_mask
|
||||||
from dzgui.views.components.buttons import (
|
from dzgui.views.components.buttons import (
|
||||||
AddButton,
|
AddButton,
|
||||||
ClipboardButton,
|
CopyIpButton,
|
||||||
SteamConnectButton,
|
SteamConnectButton,
|
||||||
)
|
)
|
||||||
from dzgui.views.components.entry import IpEntry, PortEntry
|
from dzgui.views.components.entry import IpEntry, PortEntry
|
||||||
@@ -151,7 +151,7 @@ class FavPanel(Gtk.Frame):
|
|||||||
|
|
||||||
self.fav_button = SteamConnectButton()
|
self.fav_button = SteamConnectButton()
|
||||||
self.fav_button.connect("clicked", self._on_connect_clicked)
|
self.fav_button.connect("clicked", self._on_connect_clicked)
|
||||||
self.copy_button = ClipboardButton(self.controller, self.get_fav_ip)
|
self.copy_button = CopyIpButton(self.controller, self.get_fav_ip)
|
||||||
if favorite is None:
|
if favorite is None:
|
||||||
self.toggle_buttons(False)
|
self.toggle_buttons(False)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
from typing import Literal, TYPE_CHECKING
|
from typing import Literal, TYPE_CHECKING
|
||||||
|
|
||||||
from dzgui.const.constants import (
|
from dzgui.const.constants import (
|
||||||
@@ -13,6 +14,7 @@ from dzgui.const.constants import (
|
|||||||
from dzgui.const.enum import ServerTab
|
from dzgui.const.enum import ServerTab
|
||||||
from dzgui.managers.update import UpdateManager
|
from dzgui.managers.update import UpdateManager
|
||||||
from dzgui.util.clip import copy_clipboard
|
from dzgui.util.clip import copy_clipboard
|
||||||
|
from dzgui.util.file import is_writeable
|
||||||
from dzgui.views.components.buttonbox import ButtonBox
|
from dzgui.views.components.buttonbox import ButtonBox
|
||||||
from dzgui.views.components.filter_panel import FilterPanel
|
from dzgui.views.components.filter_panel import FilterPanel
|
||||||
from dzgui.views.components.mod_panel import ModSelectionPanel
|
from dzgui.views.components.mod_panel import ModSelectionPanel
|
||||||
@@ -87,11 +89,12 @@ class RightPanel(Gtk.Box):
|
|||||||
)
|
)
|
||||||
exe_path = os.getenv("PYAPP")
|
exe_path = os.getenv("PYAPP")
|
||||||
if exe_path and update is not None:
|
if exe_path and update is not None:
|
||||||
self.update_button.set_halign(Gtk.Align.END)
|
if is_writeable(Path(exe_path)) is True:
|
||||||
self.gutter_box.add(self.update_button)
|
self.update_button.set_halign(Gtk.Align.END)
|
||||||
self.update_button.connect(
|
self.gutter_box.add(self.update_button)
|
||||||
"clicked", self._on_update_button_clicked, exe_path, update
|
self.update_button.connect(
|
||||||
)
|
"clicked", self._on_update_button_clicked, exe_path, update
|
||||||
|
)
|
||||||
self.gutter_box.add(eb)
|
self.gutter_box.add(eb)
|
||||||
self.pack_start(self.gutter_box, NO_EXPAND, FILL, NO_PADDING)
|
self.pack_start(self.gutter_box, NO_EXPAND, FILL, NO_PADDING)
|
||||||
|
|
||||||
@@ -108,7 +111,7 @@ class RightPanel(Gtk.Box):
|
|||||||
return
|
return
|
||||||
self.filters_vbox.set_sensitive(False)
|
self.filters_vbox.set_sensitive(False)
|
||||||
# TODO: unless it is lan page
|
# TODO: unless it is lan page
|
||||||
#self.refresh_button.set_sensitive(False)
|
# self.refresh_button.set_sensitive(False)
|
||||||
|
|
||||||
def _on_lan_page_init(self, emitter: "Emitter") -> None:
|
def _on_lan_page_init(self, emitter: "Emitter") -> None:
|
||||||
self.filters_vbox.set_sensitive(False)
|
self.filters_vbox.set_sensitive(False)
|
||||||
|
|||||||
@@ -0,0 +1,244 @@
|
|||||||
|
import sys
|
||||||
|
from typing import Literal, TYPE_CHECKING
|
||||||
|
|
||||||
|
# import time
|
||||||
|
from enum import Enum
|
||||||
|
from typing import Any, Self
|
||||||
|
|
||||||
|
# TODO: import dialog titles
|
||||||
|
from dzgui.api.mods import remove_stale_signatures as remove_stale
|
||||||
|
from dzgui.config.ipdb import get_ipdb
|
||||||
|
from dzgui.const.constants import HEX_GREEN, HEX_RED
|
||||||
|
from dzgui.init.coords import get_local_coords
|
||||||
|
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.strings import dialog_header
|
||||||
|
from dzgui.util.symlink import rebuild_symlinks
|
||||||
|
from dzgui.views.components.buttons import ClipboardButton
|
||||||
|
|
||||||
|
|
||||||
|
import gi
|
||||||
|
|
||||||
|
gi.require_version("Gtk", "3.0")
|
||||||
|
from gi.repository import Gtk, GLib, Gdk # noqa
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from dzgui.config.xdg import Xdg
|
||||||
|
from dzgui.util.ip import Coords
|
||||||
|
|
||||||
|
|
||||||
|
class Success(Enum):
|
||||||
|
OK = 1
|
||||||
|
FAIL = 2
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: strings for "Running", "Failed", etc.
|
||||||
|
# TODO: add margins to tree
|
||||||
|
class BootDialog(Gtk.Dialog):
|
||||||
|
def __init__(self, parent: "BootWindow", xdg: "Xdg", version: str) -> None:
|
||||||
|
super().__init__(
|
||||||
|
title=dialog_header,
|
||||||
|
parent=parent,
|
||||||
|
modal=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.parent = parent
|
||||||
|
self.set_modal(True)
|
||||||
|
self.xdg = xdg
|
||||||
|
self.version = version
|
||||||
|
|
||||||
|
self.thread_man = ThreadingManager(None)
|
||||||
|
self.set_size_request(700, 500)
|
||||||
|
|
||||||
|
self.store = Gtk.ListStore(str, str, bool, int)
|
||||||
|
|
||||||
|
self.view = Gtk.TreeView(enable_search=False, headers_visible=False)
|
||||||
|
self.view.set_model(self.store)
|
||||||
|
|
||||||
|
for i, column_title in enumerate(["Task", "State"]):
|
||||||
|
renderer = Gtk.CellRendererText()
|
||||||
|
column = Gtk.TreeViewColumn(column_title, renderer, text=i)
|
||||||
|
column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
|
||||||
|
column.set_resizable(False)
|
||||||
|
column.set_sort_column_id(i)
|
||||||
|
column.set_cell_data_func(renderer, self._format_color, func_data=None)
|
||||||
|
self.view.append_column(column)
|
||||||
|
if i == 0:
|
||||||
|
column.set_fixed_width(300)
|
||||||
|
|
||||||
|
self.spinner_renderer = Gtk.CellRendererSpinner()
|
||||||
|
self.spinner_renderer.set_property("size", Gtk.IconSize.LARGE_TOOLBAR)
|
||||||
|
col_bool = Gtk.TreeViewColumn("Spinner", self.spinner_renderer, active=3)
|
||||||
|
col_bool.set_alignment(0.0)
|
||||||
|
col_bool.set_cell_data_func(
|
||||||
|
self.spinner_renderer, self._set_spinner_vis, func_data=None
|
||||||
|
)
|
||||||
|
self.view.append_column(col_bool)
|
||||||
|
|
||||||
|
col_int = Gtk.TreeViewColumn("Int", Gtk.CellRendererText(), text=3)
|
||||||
|
col_int.set_visible(False)
|
||||||
|
self.view.append_column(col_int)
|
||||||
|
|
||||||
|
self.view.get_selection().set_mode(Gtk.SelectionMode.NONE)
|
||||||
|
self.connect("delete-event", self._on_delete)
|
||||||
|
|
||||||
|
self.scrollable_tree = Gtk.ScrolledWindow(overlay_scrolling=False)
|
||||||
|
self.scrollable_tree.add(self.view)
|
||||||
|
self.scrollable_tree.set_size_request(700, 400)
|
||||||
|
|
||||||
|
self.error_box = Gtk.Box(
|
||||||
|
halign=Gtk.Align.CENTER,
|
||||||
|
orientation=Gtk.Orientation.VERTICAL,
|
||||||
|
spacing=20,
|
||||||
|
margin_top=30,
|
||||||
|
margin_bottom=30,
|
||||||
|
)
|
||||||
|
self.error_label = Gtk.Label()
|
||||||
|
|
||||||
|
# TODO: abstract class
|
||||||
|
self.copy_button = ClipboardButton(None, lambda: self.error_label.get_text())
|
||||||
|
self.button_hbox = Gtk.Box(
|
||||||
|
orientation=Gtk.Orientation.HORIZONTAL, halign=Gtk.Align.CENTER, spacing=10
|
||||||
|
)
|
||||||
|
self.exit_button = Gtk.Button(label="Exit", halign=Gtk.Align.CENTER)
|
||||||
|
self.exit_button.connect("clicked", lambda _: sys.exit(1))
|
||||||
|
self.button_hbox.add(self.copy_button)
|
||||||
|
self.button_hbox.add(self.exit_button)
|
||||||
|
|
||||||
|
self.error_box.add(self.error_label)
|
||||||
|
self.error_box.add(self.button_hbox)
|
||||||
|
|
||||||
|
self.content = self.get_content_area()
|
||||||
|
self.content.pack_start(self.scrollable_tree, EXPAND, FILL, 0)
|
||||||
|
self.content.pack_start(self.error_box, EXPAND, FILL, 0)
|
||||||
|
self.show_all()
|
||||||
|
|
||||||
|
self.error_box.hide()
|
||||||
|
|
||||||
|
steps = [
|
||||||
|
(StoredFunc(rebuild_symlinks, self.xdg.config), preboot.symlinks, False),
|
||||||
|
(
|
||||||
|
StoredFunc(remove_stale, self.xdg.config, self.xdg.version),
|
||||||
|
preboot.signatures,
|
||||||
|
False,
|
||||||
|
),
|
||||||
|
(StoredFunc(get_ipdb, self.xdg.ips), preboot.geo, False),
|
||||||
|
(StoredFunc(get_local_coords, self.xdg.ips), preboot.coords, True),
|
||||||
|
(StoredFunc(check_updates, self.version), preboot.updates, True),
|
||||||
|
]
|
||||||
|
self.results: list[Any] = []
|
||||||
|
self.failed = False
|
||||||
|
self.steps = iter(steps)
|
||||||
|
|
||||||
|
GLib.timeout_add(100, self.pulse_spinner)
|
||||||
|
|
||||||
|
def pulse_spinner(self) -> Literal[True]:
|
||||||
|
for row in self.store:
|
||||||
|
if row[2]:
|
||||||
|
if row[3] == 150:
|
||||||
|
row[3] = 0
|
||||||
|
else:
|
||||||
|
row[3] += 1
|
||||||
|
self.spinner_renderer.set_property("pulse", row[3])
|
||||||
|
return True
|
||||||
|
|
||||||
|
def run(self) -> None:
|
||||||
|
self.iter_step()
|
||||||
|
|
||||||
|
def _on_delete(self, widget: Self, event: Gdk.Event) -> Literal[True]:
|
||||||
|
return True
|
||||||
|
|
||||||
|
def iter_step(self) -> None:
|
||||||
|
if self.failed:
|
||||||
|
self.error_box.show()
|
||||||
|
self.error_label.set_text(self.exception)
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
step, label, store_output = next(self.steps)
|
||||||
|
self.update_task(label)
|
||||||
|
self.background(step, store_output)
|
||||||
|
except StopIteration:
|
||||||
|
self.parent.set_results(self.results)
|
||||||
|
self.destroy()
|
||||||
|
|
||||||
|
@call_on_thread("", show_dialog=False)
|
||||||
|
def background(self, func: StoredFunc, store_output: bool) -> None:
|
||||||
|
try:
|
||||||
|
if store_output:
|
||||||
|
res = func.call()
|
||||||
|
self.results.append(res)
|
||||||
|
else:
|
||||||
|
func.call()
|
||||||
|
callback = StoredFunc(self.update_status, Success.OK)
|
||||||
|
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}"
|
||||||
|
callback = StoredFunc(self.update_status, Success.FAIL)
|
||||||
|
self.thread_man.set_cleanup_func(callback)
|
||||||
|
|
||||||
|
def update_task(self, task: str) -> None:
|
||||||
|
self.store.append((task, "Running", True, 0))
|
||||||
|
|
||||||
|
def update_status(self, state: Success) -> None:
|
||||||
|
d = {Success.OK: "OK", Success.FAIL: "FAILED"}
|
||||||
|
msg = d[state]
|
||||||
|
self.store[len(self.store) - 1][1] = msg
|
||||||
|
self.iter_step()
|
||||||
|
|
||||||
|
def _set_spinner_vis(
|
||||||
|
self,
|
||||||
|
column: Gtk.TreeViewColumn,
|
||||||
|
cell: Gtk.CellRendererSpinner,
|
||||||
|
model: Gtk.TreeModel,
|
||||||
|
it: Gtk.TreeIter,
|
||||||
|
data: Any,
|
||||||
|
) -> None:
|
||||||
|
if model[it][1] == "Running":
|
||||||
|
cell.set_property("visible", True)
|
||||||
|
else:
|
||||||
|
cell.set_property("visible", False)
|
||||||
|
|
||||||
|
def _format_color(
|
||||||
|
self,
|
||||||
|
column: Gtk.TreeViewColumn,
|
||||||
|
cell: Gtk.CellRendererText,
|
||||||
|
model: Gtk.TreeModel,
|
||||||
|
it: Gtk.TreeIter,
|
||||||
|
data: Any,
|
||||||
|
) -> None:
|
||||||
|
prop = "foreground"
|
||||||
|
state = model[it][1]
|
||||||
|
if column.get_sort_column_id() != 1:
|
||||||
|
return
|
||||||
|
if state == "OK":
|
||||||
|
cell.set_property(prop, HEX_GREEN)
|
||||||
|
elif state == "FAILED":
|
||||||
|
cell.set_property(prop, HEX_RED)
|
||||||
|
else:
|
||||||
|
cell.set_property(prop, None)
|
||||||
|
|
||||||
|
|
||||||
|
class BootWindow(Gtk.Window):
|
||||||
|
def __init__(self, xdg: "Xdg", version: str) -> None:
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
|
self.results: list[Any] = []
|
||||||
|
|
||||||
|
dialog = BootDialog(self, xdg, version)
|
||||||
|
dialog.run()
|
||||||
|
dialog.connect("destroy", self._on_destroy)
|
||||||
|
Gtk.main()
|
||||||
|
|
||||||
|
def set_results(self, res: list[Any]) -> None:
|
||||||
|
self.results = res
|
||||||
|
|
||||||
|
def get_results(self) -> tuple["Coords", str]:
|
||||||
|
coords, version_url = self.results
|
||||||
|
return (coords, version_url)
|
||||||
|
|
||||||
|
def _on_destroy(self, dialog: BootDialog) -> None:
|
||||||
|
Gtk.main_quit()
|
||||||
@@ -31,8 +31,6 @@ gi.require_version("Gtk", "3.0")
|
|||||||
from gi.repository import Gdk, Gtk, GLib, GObject, GdkPixbuf # noqa E402
|
from gi.repository import Gdk, Gtk, GLib, GObject, GdkPixbuf # noqa E402
|
||||||
|
|
||||||
|
|
||||||
# TODO: currently unused, corresponds to linear index
|
|
||||||
# TODO: use of pagenum enum and page_type attribute is redundant
|
|
||||||
class PageNum(Enum):
|
class PageNum(Enum):
|
||||||
INTRO = 1
|
INTRO = 1
|
||||||
HAS_CONFIG = 2
|
HAS_CONFIG = 2
|
||||||
@@ -93,6 +91,9 @@ class ScrolledWizardPage(Gtk.ScrolledWindow):
|
|||||||
|
|
||||||
self.connect("map", self._on_map)
|
self.connect("map", self._on_map)
|
||||||
|
|
||||||
|
def get_enum(self) -> PageNum:
|
||||||
|
return self.enum
|
||||||
|
|
||||||
def get_progress_bar(self) -> Progress:
|
def get_progress_bar(self) -> Progress:
|
||||||
return self.prog
|
return self.prog
|
||||||
|
|
||||||
@@ -474,6 +475,7 @@ class Assistant(Gtk.Assistant):
|
|||||||
|
|
||||||
def _advance_page(self, index: int) -> int:
|
def _advance_page(self, index: int) -> int:
|
||||||
page = self.get_nth_page(index)
|
page = self.get_nth_page(index)
|
||||||
|
# TODO: use enums
|
||||||
match page:
|
match page:
|
||||||
case self.page1:
|
case self.page1:
|
||||||
pass
|
pass
|
||||||
@@ -534,6 +536,9 @@ class Assistant(Gtk.Assistant):
|
|||||||
bar.set_text(f"{page_num}/{total}")
|
bar.set_text(f"{page_num}/{total}")
|
||||||
|
|
||||||
# NOTE: disable forward action
|
# NOTE: disable forward action
|
||||||
|
# TODO: use page enums
|
||||||
|
if page == self.page5:
|
||||||
|
return
|
||||||
if page != self.page1:
|
if page != self.page1:
|
||||||
EMITTER.emit("step_pending")
|
EMITTER.emit("step_pending")
|
||||||
|
|
||||||
|
|||||||
@@ -106,6 +106,9 @@ class PreConnectionAssistant(Gtk.ScrolledWindow):
|
|||||||
label=preconnect.back, halign=Gtk.Align.END, hexpand=True
|
label=preconnect.back, halign=Gtk.Align.END, hexpand=True
|
||||||
)
|
)
|
||||||
self.ok = Gtk.Button(label=preconnect.update_mods, halign=Gtk.Align.END)
|
self.ok = Gtk.Button(label=preconnect.update_mods, halign=Gtk.Align.END)
|
||||||
|
self.connect_last = Gtk.Button(
|
||||||
|
label=preconnect.connect_last, halign=Gtk.Align.END, tooltip_text=preconnect.connect_last_tooltip
|
||||||
|
)
|
||||||
|
|
||||||
# TODO: abstract
|
# TODO: abstract
|
||||||
self.raise_window = Gtk.CheckButton(
|
self.raise_window = Gtk.CheckButton(
|
||||||
@@ -126,13 +129,14 @@ class PreConnectionAssistant(Gtk.ScrolledWindow):
|
|||||||
spacing=5,
|
spacing=5,
|
||||||
)
|
)
|
||||||
box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
|
box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
|
||||||
for button in self.back, self.ok:
|
for button in self.back, self.ok, self.connect_last:
|
||||||
box.add(button)
|
box.add(button)
|
||||||
for el in self.raise_window, box:
|
for el in self.raise_window, box:
|
||||||
self.button_box.add(el)
|
self.button_box.add(el)
|
||||||
|
|
||||||
self.back.connect("clicked", self._on_back_clicked)
|
self.back.connect("clicked", self._on_back_clicked)
|
||||||
self.ok.connect("clicked", self._on_ok_clicked)
|
self.ok.connect("clicked", self._on_ok_clicked)
|
||||||
|
self.connect_last.connect("clicked", self._on_connect_last_clicked)
|
||||||
|
|
||||||
self.title = Gtk.Label(label="")
|
self.title = Gtk.Label(label="")
|
||||||
add_class(self.title, "preconnect-heading")
|
add_class(self.title, "preconnect-heading")
|
||||||
@@ -213,6 +217,9 @@ class PreConnectionAssistant(Gtk.ScrolledWindow):
|
|||||||
if event.keyval == Gdk.KEY_u:
|
if event.keyval == Gdk.KEY_u:
|
||||||
self.ok.emit("clicked")
|
self.ok.emit("clicked")
|
||||||
|
|
||||||
|
def _on_connect_last_clicked(self, button: Gtk.Button) -> None:
|
||||||
|
self.controller.update_and_load_to_menu(self.raise_window.get_active())
|
||||||
|
|
||||||
def _on_ok_clicked(self, button: Gtk.Button) -> None:
|
def _on_ok_clicked(self, button: Gtk.Button) -> None:
|
||||||
self.controller.update_and_connect(self.raise_window.get_active())
|
self.controller.update_and_connect(self.raise_window.get_active())
|
||||||
|
|
||||||
@@ -308,6 +315,11 @@ class PreConnectionAssistant(Gtk.ScrolledWindow):
|
|||||||
prefix = preconnect.total_mods
|
prefix = preconnect.total_mods
|
||||||
self.mod_count.set_text(f"{prefix}{str(total_mods)}.{suffix}")
|
self.mod_count.set_text(f"{prefix}{str(total_mods)}.{suffix}")
|
||||||
|
|
||||||
|
if prereqs.is_last_server:
|
||||||
|
self.connect_last.show()
|
||||||
|
else:
|
||||||
|
self.connect_last.hide()
|
||||||
|
|
||||||
self._process_warnings(prereqs)
|
self._process_warnings(prereqs)
|
||||||
if self.tree.is_visible():
|
if self.tree.is_visible():
|
||||||
self.tree.grab_focus()
|
self.tree.grab_focus()
|
||||||
|
|||||||
@@ -47,7 +47,13 @@ class ServerNotebook(Gtk.ScrolledWindow):
|
|||||||
self.recent = ServerTreeView(
|
self.recent = ServerTreeView(
|
||||||
controller, ServerTab.RECENT, ContextMenuGroup.RECENT
|
controller, ServerTab.RECENT, ContextMenuGroup.RECENT
|
||||||
)
|
)
|
||||||
self.lan = ServerTreeView(controller, ServerTab.LAN, ContextMenuGroup.SCAN_LAN)
|
self.lan = ServerTreeView(
|
||||||
|
controller,
|
||||||
|
ServerTab.LAN,
|
||||||
|
ContextMenuGroup.SCAN_LAN,
|
||||||
|
show_empty=True,
|
||||||
|
show_full=True,
|
||||||
|
)
|
||||||
|
|
||||||
tabs = [
|
tabs = [
|
||||||
(self.browser, server_labels.browser),
|
(self.browser, server_labels.browser),
|
||||||
|
|||||||
@@ -88,13 +88,12 @@ class ModTreeView(ModsMixin, ContextMixin, TreeView): # type: ignore
|
|||||||
model: Gtk.TreeModel,
|
model: Gtk.TreeModel,
|
||||||
it: Gtk.TreeIter,
|
it: Gtk.TreeIter,
|
||||||
data: Any,
|
data: Any,
|
||||||
) -> Any:
|
) -> None:
|
||||||
state = model[it][4]
|
state = model[it][4]
|
||||||
if state is True:
|
if state is True:
|
||||||
cell.set_property("foreground", HEX_RED)
|
cell.set_property("foreground", HEX_RED)
|
||||||
else:
|
else:
|
||||||
cell.set_property("foreground", None)
|
cell.set_property("foreground", None)
|
||||||
return
|
|
||||||
|
|
||||||
def _format_float(
|
def _format_float(
|
||||||
self,
|
self,
|
||||||
@@ -103,8 +102,7 @@ class ModTreeView(ModsMixin, ContextMixin, TreeView): # type: ignore
|
|||||||
model: Gtk.TreeModel,
|
model: Gtk.TreeModel,
|
||||||
it: Gtk.TreeIter,
|
it: Gtk.TreeIter,
|
||||||
data: Any,
|
data: Any,
|
||||||
) -> Any:
|
) -> None:
|
||||||
val = model[it][3]
|
val = model[it][3]
|
||||||
formatted = localize.number(val)
|
formatted = localize.number(val)
|
||||||
cell.set_property("text", formatted)
|
cell.set_property("text", formatted)
|
||||||
return
|
|
||||||
@@ -38,7 +38,12 @@ QUEUE_CHECK_DELAY = 200
|
|||||||
|
|
||||||
class ServerTreeView(ContextMixin, TreeView): # type: ignore
|
class ServerTreeView(ContextMixin, TreeView): # type: ignore
|
||||||
def __init__(
|
def __init__(
|
||||||
self, controller: "Controller", enum: ServerTab, menu: ContextMenuGroup
|
self,
|
||||||
|
controller: "Controller",
|
||||||
|
enum: ServerTab,
|
||||||
|
menu: ContextMenuGroup,
|
||||||
|
show_empty: bool = False,
|
||||||
|
show_full: bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__(controller, menu=menu)
|
super().__init__(controller, menu=menu)
|
||||||
|
|
||||||
@@ -48,7 +53,7 @@ class ServerTreeView(ContextMixin, TreeView): # type: ignore
|
|||||||
|
|
||||||
self.loaded = False
|
self.loaded = False
|
||||||
|
|
||||||
self.filter_man = FilterManager()
|
self.filter_man = FilterManager(show_empty, show_full)
|
||||||
self.proxy_man = ProxyModelManager(self.filter_man)
|
self.proxy_man = ProxyModelManager(self.filter_man)
|
||||||
model = self.proxy_man.get_proxy_model()
|
model = self.proxy_man.get_proxy_model()
|
||||||
self.set_model(model)
|
self.set_model(model)
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ description = "DayZ server browser and mod manager for Linux"
|
|||||||
authors = [
|
authors = [
|
||||||
{name = "aclist"}
|
{name = "aclist"}
|
||||||
]
|
]
|
||||||
version = "7.0.0b6"
|
version = "7.0.0b8"
|
||||||
license = "GPL-3.0-or-later"
|
license = "GPL-3.0-or-later"
|
||||||
license-files = ["LICENSE"]
|
license-files = ["LICENSE"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|||||||
+5
-2
@@ -53,7 +53,8 @@ def untar(file: str, glob: str, renamed: str) -> None:
|
|||||||
|
|
||||||
def install_deps() -> None:
|
def install_deps() -> None:
|
||||||
pip = build_dir.joinpath(f"{CPYTHON_BUILD}/bin/pip")
|
pip = build_dir.joinpath(f"{CPYTHON_BUILD}/bin/pip")
|
||||||
subprocess.run([pip, "install", root])
|
proc = subprocess.run([pip, "install", root])
|
||||||
|
return proc.returncode
|
||||||
|
|
||||||
|
|
||||||
def repackage() -> None:
|
def repackage() -> None:
|
||||||
@@ -66,7 +67,9 @@ def repackage() -> None:
|
|||||||
def rebuild_cpython() -> None:
|
def rebuild_cpython() -> None:
|
||||||
if cpython_dir.is_dir() is False:
|
if cpython_dir.is_dir() is False:
|
||||||
get_cpython()
|
get_cpython()
|
||||||
install_deps()
|
code = install_deps()
|
||||||
|
if code != 0:
|
||||||
|
return
|
||||||
repackage()
|
repackage()
|
||||||
return get_packaged_version()
|
return get_packaged_version()
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -51,7 +51,11 @@ if proc.returncode == 0:
|
|||||||
output_exe.rename(release_exe)
|
output_exe.rename(release_exe)
|
||||||
tarpath = output.joinpath(tarname)
|
tarpath = output.joinpath(tarname)
|
||||||
with tarfile.open(tarpath, "w:gz") as tar:
|
with tarfile.open(tarpath, "w:gz") as tar:
|
||||||
tar.add(release_exe, arcname=appname)
|
info = tar.gettarinfo(release_exe)
|
||||||
|
info.uname = appname
|
||||||
|
info.name = appname
|
||||||
|
with open(release_exe, "rb") as f:
|
||||||
|
tar.addfile(info, f)
|
||||||
print(f"Wrote tarfile to '{tarpath}'")
|
print(f"Wrote tarfile to '{tarpath}'")
|
||||||
|
|
||||||
proc = subprocess.run([release_exe, "-v"], capture_output=True, text=True)
|
proc = subprocess.run([release_exe, "-v"], capture_output=True, text=True)
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
from dzgui.config.ipdb import get_ipdb
|
||||||
|
from pathlib import Path
|
||||||
|
import os
|
||||||
|
import pytest
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.slow
|
||||||
|
def test_stripping():
|
||||||
|
d = tempfile.TemporaryDirectory()
|
||||||
|
path = Path(d.name).joinpath("ips.csv")
|
||||||
|
get_ipdb(path)
|
||||||
|
with open(path, "rb") as f:
|
||||||
|
first = f.readline().decode().rstrip()
|
||||||
|
try:
|
||||||
|
f.seek(-2, os.SEEK_END)
|
||||||
|
while f.read(1) != b"\n":
|
||||||
|
f.seek(-2, os.SEEK_CUR)
|
||||||
|
except OSError:
|
||||||
|
f.seek(0)
|
||||||
|
last = f.read().decode().rstrip()
|
||||||
|
|
||||||
|
first_els = first.split(",")
|
||||||
|
last_els = last.split(",")
|
||||||
|
|
||||||
|
assert first_els[0] == "0.0.0.0"
|
||||||
|
assert last_els[0] == "224.0.0.0"
|
||||||
Reference in new issue
Block a user