feat: dzgui 7 alpha

This commit is contained in:
aclist committed 2025-12-08 17:32:25 +09:00
1 parent 1acdbd58c5
commit 2e5b771137
150 files changed
+10359

No files matched your search

+88
View File
@@ -0,0 +1,88 @@
import os
import platform
import re
import textwrap
from datetime import datetime
from pathlib import Path
from dzgui.api.mods import get_local_mod_ids, get_local_mod_path
from dzgui.const.constants import APP_NAME
from dzgui.const.enum import Preferences
from dzgui.config.query import lookup
from dzgui.init.prefix import get_version
from dzgui.util.redact import redact
def get_cpu_model() -> str:
cpuinfo = Path("/proc/cpuinfo")
text = cpuinfo.read_text()
lines = text.split("\n")
for i, line in enumerate(lines):
if line.startswith("model name"):
model = line.split(": ")[1]
return model
return ""
def print_servers(servers: list[str]) -> str:
s = ""
for server in servers:
s+= server + "\n"
return s
def print_mods(mods: list[int]) -> str:
s = ""
for mod in mods:
s+= str(mod) + "\n"
return s
def write_diagnostic(config: Path, outfile: Path) -> None:
# TODO: test availability on other distros
date = datetime.now().isoformat()
distro = platform.freedesktop_os_release()["ID_LIKE"]
kernel = os.uname().release
cpu = get_cpu_model()
version = get_version()
branch = lookup(config, Preferences.BRANCH)
debug = lookup(config, Preferences.DEBUG)
install = lookup(config, Preferences.INSTALL)
default = lookup(config, Preferences.DEFAULT)
steam_path = Path(default)
workshop_path = get_local_mod_path(steam_path)
steam_redacted = redact(default)
workshop_redacted = redact(str(workshop_path))
mods = get_local_mod_ids(steam_path)
mods_pretty = print_mods(mods)
servers = lookup(config, Preferences.IP_LIST)
servers_pretty = print_servers(servers)
# FIXME: extraneous newlines in lists
template = f"""\
{APP_NAME} version {version} ({branch})
Date: {date}
===============================
Distribution: {distro}
Kernel: {kernel}
CPU: {cpu}
Debug: {debug}
Auto-install: {install}
Steam path: {steam_redacted}
Workshop path: {workshop_redacted}
Mods:
{mods_pretty}
Servers:
{servers_pretty}
"""
output = "\n".join([line.lstrip() for line in template.split('\n')])
outfile.write_text(output)