Compare commits

..
Author SHA1 Message Date
aclist 5423d9ad56 chore: add strings file 2026-11-21 20:47:28 +09:00
aclist 1aed045149 feat: export debug log to a named file 2026-11-21 20:45:28 +09:00
9 changed files with 69 additions and 86 deletions

No files matched your search

+1 -1
View File
@@ -23,7 +23,7 @@ def has_flatpak_client() -> bool:
else: else:
return False return False
except Exception as e: except Exception as e:
logger.debug(e) logger.critical(e)
return False return False
-2
View File
@@ -347,9 +347,7 @@ thanks = Thanks(
"scandalouss", "scandalouss",
"SnackSBR", "SnackSBR",
"StevelDusa", "StevelDusa",
"sylvaingirardbe",
"Thoughtduck216", "Thoughtduck216",
"u-alexandru",
], ],
) )
+2 -2
View File
@@ -19,7 +19,7 @@ from dzgui.views.components.buttons import ClipboardButton
from dzgui.views.mixins.colorscheme import ColorAwareApp from dzgui.views.mixins.colorscheme import ColorAwareApp
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, GLib, Gdk, Pango from gi.repository import Gtk, GLib, Gdk
if TYPE_CHECKING: if TYPE_CHECKING:
from dzgui.config.xdg import Xdg from dzgui.config.xdg import Xdg
@@ -95,7 +95,7 @@ class BootDialog(ColorAwareApp, Gtk.Dialog): # type: ignore
margin_top=30, margin_top=30,
margin_bottom=30, margin_bottom=30,
) )
self.error_label = Gtk.Label(margin_start=15, margin_end=15, wrap=True, wrap_mode=Pango.WrapMode.WORD) self.error_label = Gtk.Label(margin_start=15, margin_end=15)
# TODO: abstract class # TODO: abstract class
self.copy_button = ClipboardButton(self.error_label.get_text) self.copy_button = ClipboardButton(self.error_label.get_text)
+1 -2
View File
@@ -1,9 +1,8 @@
import tomllib import tomllib
from shared import get_git_root from shared import get_git_root
from typing import Any
def get_entrypoint() -> Any: def get_entrypoint() -> None:
root = get_git_root() root = get_git_root()
p = root.joinpath("pyproject.toml") p = root.joinpath("pyproject.toml")
with open(p, "rb") as f: with open(p, "rb") as f:
+3 -3
View File
@@ -52,7 +52,7 @@ def untar(file: str, glob: str, renamed: str) -> None:
os.rename(_dir, build_dir.joinpath(renamed)) os.rename(_dir, build_dir.joinpath(renamed))
def install_deps() -> int: def install_deps() -> None:
pip = build_dir.joinpath(f"{CPYTHON_BUILD}/bin/pip") pip = build_dir.joinpath(f"{CPYTHON_BUILD}/bin/pip")
proc = subprocess.run([pip, "install", root]) proc = subprocess.run([pip, "install", root])
return proc.returncode return proc.returncode
@@ -65,12 +65,12 @@ def repackage() -> None:
tar.add(build_dir.joinpath(CPYTHON_BUILD), arcname="python") tar.add(build_dir.joinpath(CPYTHON_BUILD), arcname="python")
def rebuild_cpython() -> str: def rebuild_cpython() -> None:
if cpython_dir.is_dir() is False: if cpython_dir.is_dir() is False:
get_cpython() get_cpython()
code = install_deps() code = install_deps()
if code != 0: if code != 0:
return "" return
repackage() repackage()
return get_packaged_version() return get_packaged_version()
+2 -2
View File
@@ -92,8 +92,8 @@ with tarfile.open(tarpath, "w:gz") as tar:
tar.add(subfolder, arcname=appname, filter=update_uname) tar.add(subfolder, arcname=appname, filter=update_uname)
print(f"Wrote tarfile to '{tarpath}'") print(f"Wrote tarfile to '{tarpath}'")
built_proc = subprocess.run([release_exe, "-v"], capture_output=True, text=True) proc = subprocess.run([release_exe, "-v"], capture_output=True, text=True)
assert str(built_proc.stdout).rstrip() == version assert proc.stdout.rstrip() == version
# TODO: clean up staging directory # TODO: clean up staging directory
release_exe.unlink() release_exe.unlink()
-6
View File
@@ -8,13 +8,7 @@ def get_image_path() -> Path:
return get_git_root().joinpath("dzgui/data/images/example.png") return get_git_root().joinpath("dzgui/data/images/example.png")
def take_screenshot() -> None:
p = get_image_path() p = get_image_path()
app = build_gui("", False) app = build_gui("", False)
if app is None:
return
app.set_automation_param("screenshot_path", p) app.set_automation_param("screenshot_path", p)
app.run(None) app.run(None)
take_screenshot()
+10 -5
View File
@@ -3,9 +3,14 @@ import subprocess
import sys import sys
cmd = ["git", "ls-files", "--others", "--exclude-standard"] cmd = ["git", "ls-files", "--others", "--exclude-standard"]
result = subprocess.run(cmd, capture_output=True, text=True) result = subprocess.Popen(
untracked = [os.path.basename(line.rstrip()) for line in result.stdout.splitlines()] cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True
if bool(untracked): )
print("The following files are untracked. Add to .gitignore if this is intended.") with open(".gitignore", "r") as f:
print("\n".join(untracked)) ignored = [line.rstrip() for line in f]
untracked = [os.path.basename(line.rstrip()) for line in result.stdout]
for file in untracked:
if not any(file in item for item in ignored):
print(f"File '{file}' is untracked. Add to .gitignore file if this is intended.")
sys.exit(1) sys.exit(1)
+50 -63
View File
@@ -1,93 +1,80 @@
import pytest import pytest
import unittest
from typing import Literal, TYPE_CHECKING from unittest.mock import patch
from typing import Any
from dzgui.const.constants import ( from dzgui.const.constants import (
FLATPAK_APPID, FLATPAK_APPID,
FLATPAK_ROOT_PATH, FLATPAK_ROOT_PATH,
FLATPAK_RUN_CMD,
FLATPAK_SANDBOX,
) )
from dzgui.init import proc from dzgui.init import proc
if TYPE_CHECKING:
from _pytest.monkeypatch import MonkeyPatch
pytestmark = pytest.mark.flatpak pytestmark = pytest.mark.flatpak
def mock_has_cmd(cmd: str) -> Literal[True]: class TestSteamDetection(unittest.TestCase):
return True def test_flatpak_detection_with_multiple_running_apps(self) -> None:
def flatpak_output(args: Any, *, text: str) -> str:
# Default 'flatpak ps' includes instance, PID, app and runtime columns.
if args == ["flatpak", "ps", "--columns=application"]:
return f"com.spotify.Client\n{FLATPAK_APPID}\n{FLATPAK_APPID}\n"
return f"3904921611\t1257689\t{FLATPAK_APPID}\torg.freedesktop.Platform\n"
with (
patch.object(proc, "has_cmd", return_value=True),
patch.object(proc.subprocess, "check_output", side_effect=flatpak_output),
):
for client in (FLATPAK_RUN_CMD, FLATPAK_SANDBOX):
with self.subTest(client=client):
self.assertTrue(proc.is_steam_running(client))
def mock_has_not_cmd(cmd: str) -> Literal[False]: def test_flatpak_not_running(self) -> None:
return False with patch.object(proc, "has_cmd", return_value=True):
for output in ("", "com.spotify.Client\n", f"{FLATPAK_APPID}Helper\n"):
with (
self.subTest(output=output),
patch.object(proc.subprocess, "check_output", return_value=output),
):
self.assertFalse(proc.is_flatpak_steam_running())
def test_flatpak_not_installed(self) -> None:
with (
patch.object(proc, "has_cmd", return_value=False),
patch.object(proc.subprocess, "check_output") as check_output,
):
self.assertFalse(proc.is_flatpak_steam_running())
check_output.assert_not_called()
def mock_get_flatpak_output() -> list[str]: def test_native_steam(self) -> None:
lines = ["Application", "com.freedesktop.Platform", f"{FLATPAK_APPID}"] with patch.object(proc, "has_cmd", return_value=True):
return lines for output, expected in (
@pytest.mark.parametrize(
"output, expected",
[
( (
[ [
[f"/home/user/{FLATPAK_ROOT_PATH}/.local/share/Steam"], [FLATPAK_ROOT_PATH],
["/home/user/.local/share/Steam/ubuntu12_64/steamwebhelper"], "/home/user/.local/share/Steam/ubuntu12_64/steamwebhelper",
], ],
True, True,
), ),
( ([[FLATPAK_ROOT_PATH]], False),
[ ([[FLATPAK_ROOT_PATH], ["steam-runtime-launcher-service"]], False),
[f"/home/user/{FLATPAK_ROOT_PATH}/.local/share/Steam"],
["steam-runtime-launcher-service"],
],
False,
),
([[f"/home/user/{FLATPAK_ROOT_PATH}/.local/share/Steam"]], False),
([["/home/user/.local/share/Steam/ubuntu12_64/steamwebhelper"]], True), ([["/home/user/.local/share/Steam/ubuntu12_64/steamwebhelper"]], True),
( (
[ [
["/home/user/.local/share/Steam/ubuntu12_64/steamwebhelper"], ["/home/user/.local/share/Steam/ubuntu12_64/steamwebhelper"],
["steam-runtime-launcher-service"], "steam-runtime-launcher-service",
], ],
True, True,
), ),
], ):
) with (
def test_native_steam_running( self.subTest(running=output),
monkeypatch: "MonkeyPatch", output: list[list[str]], expected: bool patch.object(proc, "get_steam_procs", return_value=output),
) -> None: ):
def mock_get_steam_procs() -> list[list[str]]: self.assertEqual(proc.is_native_steam_running(), expected)
return output
monkeypatch.setattr("dzgui.init.proc.has_cmd", mock_has_cmd) def test_invalid_client(self) -> None:
monkeypatch.setattr("dzgui.init.proc.get_steam_procs", mock_get_steam_procs) with self.assertRaises(TypeError):
assert proc.is_native_steam_running() == expected
def test_flatpak_running(monkeypatch: "MonkeyPatch") -> None:
monkeypatch.setattr("dzgui.init.proc.has_cmd", mock_has_cmd)
monkeypatch.setattr("dzgui.init.proc.get_flatpak_output", mock_get_flatpak_output)
assert proc.is_flatpak_steam_running()
def test_flatpak_sandboxed(monkeypatch: "MonkeyPatch") -> None:
monkeypatch.setattr("dzgui.init.proc.has_cmd", mock_has_not_cmd)
monkeypatch.setenv("FLATPAK_ID", FLATPAK_APPID)
assert proc.is_flatpak_steam_running()
def test_flatpak_not_installed(monkeypatch: "MonkeyPatch") -> None:
monkeypatch.setattr("dzgui.init.proc.has_cmd", mock_has_not_cmd)
assert not proc.is_flatpak_steam_running()
def test_steam_not_installed(monkeypatch: "MonkeyPatch") -> None:
monkeypatch.setattr("dzgui.init.proc.has_cmd", mock_has_not_cmd)
assert not proc.is_native_steam_running()
def test_invalid_client() -> None:
with pytest.raises(TypeError):
proc.is_steam_running("invalid-client") proc.is_steam_running("invalid-client")