mirror of
https://github.com/aclist/dztui.git
synced 2026-10-30 22:52:42 +01:00
chore: merge main
This commit is contained in:
commit
3cdc36c78b
7 files changed
+90
-8
No files matched your search
@@ -13,6 +13,7 @@
|
|||||||
- Documentation ships with source
|
- Documentation ships with source
|
||||||
- Open filepicker when generating system log
|
- Open filepicker when generating system log
|
||||||
- Developers page (and -d flag)
|
- Developers page (and -d flag)
|
||||||
|
- Redact API key in log table
|
||||||
|
|
||||||
## Changed
|
## Changed
|
||||||
- Reduce padding on keys button
|
- Reduce padding on keys button
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import threading
|
import threading
|
||||||
import textwrap
|
import textwrap
|
||||||
@@ -43,6 +44,8 @@ from dzgui.util import cooldown, strings
|
|||||||
from dzgui.util._json import read_json, write_json
|
from dzgui.util._json import read_json, write_json
|
||||||
from dzgui.util.open_links import open_workshop_page
|
from dzgui.util.open_links import open_workshop_page
|
||||||
from dzgui.util.format import format_mods
|
from dzgui.util.format import format_mods
|
||||||
|
from dzgui.util.redact import redact_log
|
||||||
|
|
||||||
from dzgui.views.dialogs.filepicker import FilePicker
|
from dzgui.views.dialogs.filepicker import FilePicker
|
||||||
from dzgui.views.dialogs.generic import GenericDialog
|
from dzgui.views.dialogs.generic import GenericDialog
|
||||||
|
|
||||||
@@ -437,7 +440,8 @@ class Controller:
|
|||||||
with open(log, "r") as f:
|
with open(log, "r") as f:
|
||||||
lines = [line.split(strings.delimiter) for line in f.read().splitlines()]
|
lines = [line.split(strings.delimiter) for line in f.read().splitlines()]
|
||||||
for record in lines:
|
for record in lines:
|
||||||
store.append(record)
|
clean = redact_log(record)
|
||||||
|
store.append(clean)
|
||||||
self.open_page(NotebookPage.LOG)
|
self.open_page(NotebookPage.LOG)
|
||||||
|
|
||||||
def select_colorized(self) -> None:
|
def select_colorized(self) -> None:
|
||||||
|
|||||||
@@ -1,25 +1,80 @@
|
|||||||
import gi
|
import gi
|
||||||
gi.require_version("Gtk", "3.0")
|
gi.require_version("Gtk", "3.0")
|
||||||
from gi.repository.Gtk import ListStore
|
from gi.repository.Gtk import ListStore
|
||||||
|
from gi.repository import GObject
|
||||||
|
|
||||||
from dzgui.const.enum import FilterMode
|
from dzgui.const.enum import FilterMode
|
||||||
|
|
||||||
|
from dataclasses import dataclass, fields
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
@dataclass(slots=True, frozen=True)
|
||||||
|
class ServerColumns:
|
||||||
|
name: str
|
||||||
|
_map: str
|
||||||
|
perspective: str
|
||||||
|
gametime: str
|
||||||
|
players: int
|
||||||
|
_max: int
|
||||||
|
queue: int
|
||||||
|
ip: str
|
||||||
|
qport: int
|
||||||
|
ping: int
|
||||||
|
provider: str
|
||||||
|
modded: bool
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass(slots=True, frozen=True)
|
||||||
|
class ModCols:
|
||||||
|
name: str
|
||||||
|
symlink: str
|
||||||
|
directory: str
|
||||||
|
size: float
|
||||||
|
color: str
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass(slots=True, frozen=True)
|
||||||
|
class LogCols:
|
||||||
|
timestamp: str
|
||||||
|
flag: str
|
||||||
|
traceback: str
|
||||||
|
msg: str
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass(slots=True, frozen=True)
|
||||||
|
class ServerModCols:
|
||||||
|
name: str
|
||||||
|
uid: GObject.TYPE_INT64
|
||||||
|
installed: str
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass(slots=True, frozen=True)
|
||||||
|
class MenuCols:
|
||||||
|
name: str
|
||||||
|
hidden: GObject.TYPE_PYOBJECT
|
||||||
|
|
||||||
|
|
||||||
class ModelManager:
|
class ModelManager:
|
||||||
"""
|
"""
|
||||||
Manages access to cached ListStore resources and
|
Manages access to cached ListStore resources and
|
||||||
performs filtering on behalf of TreeViews.
|
performs filtering on behalf of TreeViews.
|
||||||
|
|
||||||
Not thread-safe.
|
Methods are not thread-safe in themselves.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# NOTE: packed ListStores
|
|
||||||
self.filter_cache = {}
|
self.filter_cache = {}
|
||||||
self.ping_cache = {}
|
self.ping_cache = {}
|
||||||
|
|
||||||
self.mod_store = ListStore(str, str, str, float, str)
|
self.map_store = ListStore(str)
|
||||||
|
self.row_store = self.new_model_from_class(MenuCols)
|
||||||
|
self.help_store = self.new_model_from_class(MenuCols)
|
||||||
|
|
||||||
# NOTE: stringwise (list) representation of the model
|
self.mod_store = self.new_model_from_class(ModCols)
|
||||||
|
self.log_store = self.new_model_from_class(LogCols)
|
||||||
|
self.modlist_store = self.new_model_from_class(ServerModCols)
|
||||||
|
|
||||||
|
#self.mod_store = ListStore(str, str, str, float, str)
|
||||||
self.control_model = None
|
self.control_model = None
|
||||||
self.filtered = None
|
self.filtered = None
|
||||||
self.success = True
|
self.success = True
|
||||||
@@ -29,6 +84,10 @@ class ModelManager:
|
|||||||
cls.instance = super(ModelManager, cls).__new__(cls)
|
cls.instance = super(ModelManager, cls).__new__(cls)
|
||||||
return cls.instance
|
return cls.instance
|
||||||
|
|
||||||
|
def new_model_from_class(self, cls: type) -> ListStore:
|
||||||
|
store = ListStore(*[ftype for field, ftype in cls.__annotations__.items()])
|
||||||
|
return store
|
||||||
|
|
||||||
def get_mod_store(self) -> ListStore:
|
def get_mod_store(self) -> ListStore:
|
||||||
return self.mod_store
|
return self.mod_store
|
||||||
|
|
||||||
@@ -200,9 +259,8 @@ class ModelManager:
|
|||||||
self.filter_cache[filters] = (model, rows)
|
self.filter_cache[filters] = (model, rows)
|
||||||
|
|
||||||
def new_model(self) -> ListStore:
|
def new_model(self) -> ListStore:
|
||||||
return ListStore(
|
store = self.new_model_from_class(ServerColumns)
|
||||||
str, str, str, str, int, int, int, str, int, int, str, bool
|
return store
|
||||||
)
|
|
||||||
|
|
||||||
def resync_model(self, addr: str, qport: int) -> None:
|
def resync_model(self, addr: str, qport: int) -> None:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
- Documentation ships with source
|
- Documentation ships with source
|
||||||
- Open filepicker when generating system log
|
- Open filepicker when generating system log
|
||||||
- Developers page (and -d flag)
|
- Developers page (and -d flag)
|
||||||
|
- Redact API key in log table
|
||||||
|
|
||||||
## Changed
|
## Changed
|
||||||
- Reduce padding on keys button
|
- Reduce padding on keys button
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ def migrate_legacy_conf(config: Path) -> None:
|
|||||||
old_conf = Path.home() / LEGACY_CONFIG_PATH
|
old_conf = Path.home() / LEGACY_CONFIG_PATH
|
||||||
if old_conf.is_file():
|
if old_conf.is_file():
|
||||||
j = rc2json(old_conf)
|
j = rc2json(old_conf)
|
||||||
|
# FIXME: superfluous use of Path()
|
||||||
Path(config).parent.mkdir(parents=True, exist_ok=True)
|
Path(config).parent.mkdir(parents=True, exist_ok=True)
|
||||||
config.write_text(j)
|
config.write_text(j)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -4,3 +4,17 @@ def redact(text: str) -> str:
|
|||||||
r = r"(/home/)([^/])*"
|
r = r"(/home/)([^/])*"
|
||||||
cleaned = re.sub(r, r"/home/REDACTED", text)
|
cleaned = re.sub(r, r"/home/REDACTED", text)
|
||||||
return cleaned
|
return cleaned
|
||||||
|
|
||||||
|
def redact_log(record: list) -> list[str]:
|
||||||
|
"""
|
||||||
|
requests library includes Steam API key in URL params
|
||||||
|
"""
|
||||||
|
clean = []
|
||||||
|
for item in record:
|
||||||
|
if "&key=" in item:
|
||||||
|
pat = r"(.*&key=)(\S+)(.*)"
|
||||||
|
scrubbed = re.sub(pat, r"\1REDACTED\3", item)
|
||||||
|
clean.append(scrubbed)
|
||||||
|
else:
|
||||||
|
clean.append(item)
|
||||||
|
return clean
|
||||||
@@ -487,8 +487,11 @@ class Options(Gtk.Box):
|
|||||||
|
|
||||||
|
|
||||||
active_combo = 1 if config["branch"] == BETA_REPO else 0
|
active_combo = 1 if config["branch"] == BETA_REPO else 0
|
||||||
|
|
||||||
|
self.controller.suppress_signal(self, self.branch_combo, "_on_branch_changed", True)
|
||||||
self.branch_combo.set_active(active_combo)
|
self.branch_combo.set_active(active_combo)
|
||||||
self.branch_combo.set_sensitive(prefs.allow_updates)
|
self.branch_combo.set_sensitive(prefs.allow_updates)
|
||||||
|
self.controller.suppress_signal(self, self.branch_combo, "_on_branch_changed", False)
|
||||||
|
|
||||||
if prefs.allow_updates is True:
|
if prefs.allow_updates is True:
|
||||||
msg = strings.options.self_update
|
msg = strings.options.self_update
|
||||||
|
|||||||
Reference in new issue
Block a user