a2qlinux 0.4.0__tar.gz → 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/CHANGELOG.md +32 -0
  2. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/PKG-INFO +5 -4
  3. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/README.md +4 -3
  4. a2qlinux-0.5.0/a2qlinux/__init__.py +30 -0
  5. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/a2qlinux/_version.py +2 -2
  6. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/a2qlinux/bin/questlog_ctl.exe +0 -0
  7. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/a2qlinux/bin/wpcap.dll +0 -0
  8. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/a2qlinux/desktop.py +7 -0
  9. a2qlinux-0.5.0/a2qlinux/diagnose.py +405 -0
  10. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/a2qlinux/launcher.py +101 -3
  11. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/a2qlinux/setup_desktop.py +37 -4
  12. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/a2qlinux/tray.py +6 -1
  13. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/bridge/questlog_ctl.c +5 -1
  14. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/docs/ARCHITECTURE.md +174 -10
  15. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/docs/INSTALL.md +4 -3
  16. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/docs/README.md +2 -2
  17. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/docs/TROUBLESHOOTING.md +41 -2
  18. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/docs/UPDATING.md +3 -1
  19. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/docs/USING.md +43 -5
  20. a2qlinux-0.5.0/tests/test_diagnose.py +111 -0
  21. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/tests/test_launcher.py +69 -3
  22. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/tests/test_setup_desktop.py +29 -0
  23. a2qlinux-0.5.0/tests/test_version.py +39 -0
  24. a2qlinux-0.4.0/a2qlinux/__init__.py +0 -6
  25. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/.gitignore +0 -0
  26. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/LICENSE +0 -0
  27. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/a2qlinux/config.py +0 -0
  28. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/a2qlinux/kde_overlays.py +0 -0
  29. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/a2qlinux/pcap_bridge.py +0 -0
  30. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/a2qlinux/steam.py +0 -0
  31. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/a2qlinux/update.py +0 -0
  32. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/bridge/build.sh +0 -0
  33. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/bridge/tests/bridge_client_test.c +0 -0
  34. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/bridge/tests/zorder_guard_test.c +0 -0
  35. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/bridge/wpcap_bridge.c +0 -0
  36. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/docs/RELEASE.md +0 -0
  37. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/pyproject.toml +0 -0
  38. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/tests/__init__.py +0 -0
  39. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/tests/test_config.py +0 -0
  40. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/tests/test_desktop.py +0 -0
  41. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/tests/test_kde_overlays.py +0 -0
  42. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/tests/test_pcap_bridge.py +0 -0
  43. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/tests/test_replay_stream.py +0 -0
  44. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/tests/test_steam.py +0 -0
  45. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/tests/test_update.py +0 -0
  46. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/tools/__init__.py +0 -0
  47. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/tools/pcap2questlog.py +0 -0
  48. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/tools/replay_stream.py +0 -0
  49. {a2qlinux-0.4.0 → a2qlinux-0.5.0}/tools/tcp_owner_probe.c +0 -0
@@ -3,6 +3,38 @@
3
3
  What changed for players, release by release. Technical details are in
4
4
  `docs/ARCHITECTURE.md`.
5
5
 
6
+ ## [0.5.0] — 2026-11-10
7
+
8
+ ### Added
9
+ - `a2qlinux --diagnose` checks what A2Qlinux needs and how AION 2 is
10
+ started from Steam, without changing anything, and prints one line per
11
+ check: `ok`, `note`, or `PROBLEM` with what to do. It notices, for
12
+ example, a missing Steam launch option, one that keeps the game from
13
+ starting, and a Questlog that was started outside A2Qlinux, which the
14
+ game would wait for.
15
+ - `a2qlinux --diagnose --report` also writes a report file with that
16
+ diagnosis and A2Qlinux's recent messages, with the home folder, user
17
+ name, computer name, Steam account number and network addresses
18
+ replaced, shows it, and on request opens a filled-in GitHub issue in
19
+ the browser. Nothing is sent until the issue is submitted.
20
+ - Which A2Qlinux runs is shown as the first, greyed-out line of the tray
21
+ icon's menu, when hovering over the icon, as the first line of the
22
+ status window, and by `a2qlinux --version`.
23
+ - Everything the status window shows is also kept, with the time, in
24
+ `launcher.log` in the `proton-stream` folder inside Questlog's folder,
25
+ so it is still there after the window has closed. At most 2 MB are
26
+ kept.
27
+
28
+ ### Changed
29
+ - At its end, `a2qlinux-setup` says whether AION 2's Steam launch option
30
+ is set, and prints the line to paste only when it is not. A launch
31
+ option that keeps the game from starting (without `%command%`, or
32
+ pointing at a file that is gone) is listed as a problem.
33
+ - The terminal no longer shows the lines `Capturing on '…'` and
34
+ `File: -`, which looked like a file being sent somewhere. Messages
35
+ from the capture program now appear in the status window marked
36
+ `dumpcap on <connection>:`.
37
+
6
38
  ## [0.4.0] — 2026-11-09
7
39
 
8
40
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: a2qlinux
3
- Version: 0.4.0
3
+ Version: 0.5.0
4
4
  Summary: Questlog Desktop (AION 2 damage meter) on Linux under Proton, with live game traffic.
5
5
  Project-URL: homepage, https://github.com/raman78/A2Qlinux
6
6
  Project-URL: repository, https://github.com/raman78/A2Qlinux
@@ -71,7 +71,7 @@ game:
71
71
  back if they do not start.
72
72
 
73
73
  Status: in daily use on CachyOS, KDE Plasma 6 (Wayland), Proton 11
74
- (`proton-cachyos-slr`), Questlog 0.1.37. Other distributions and desktops
74
+ (`proton-cachyos-slr`), Questlog 0.1.51. Other distributions and desktops
75
75
  are untested; what they need (Steam from the distribution or Valve, not
76
76
  Flatpak; a system tray; Python 3.11 or newer; the packages per distribution)
77
77
  is in [docs/INSTALL.md](https://github.com/raman78/A2Qlinux/blob/main/docs/INSTALL.md#what-you-need-before-you-start).
@@ -90,7 +90,7 @@ for Arch, Debian, Ubuntu, Fedora and openSUSE. In short:
90
90
  everything else and prints the command for anything still missing — see
91
91
  [Installing A2Qlinux and Questlog](https://github.com/raman78/A2Qlinux/blob/main/docs/INSTALL.md#installing-a2qlinux-and-questlog).
92
92
  4. Start **Questlog (AION 2)** from the menu, or set the Steam launch option
93
- that `a2qlinux-setup` prints.
93
+ that `a2qlinux-setup` prints (it says when the option is already set).
94
94
 
95
95
  ## Documentation
96
96
 
@@ -98,7 +98,8 @@ for Arch, Debian, Ubuntu, Fedora and openSUSE. In short:
98
98
  - [docs/USING.md](https://github.com/raman78/A2Qlinux/blob/main/docs/USING.md) — starting, tray icon, playing.
99
99
  - [docs/UPDATING.md](https://github.com/raman78/A2Qlinux/blob/main/docs/UPDATING.md) — Questlog updates, installing Questlog
100
100
  by hand, and updating A2Qlinux itself (`pipx upgrade a2qlinux`).
101
- - [docs/TROUBLESHOOTING.md](https://github.com/raman78/A2Qlinux/blob/main/docs/TROUBLESHOOTING.md) — problems, FAQ.
101
+ - [docs/TROUBLESHOOTING.md](https://github.com/raman78/A2Qlinux/blob/main/docs/TROUBLESHOOTING.md) — problems, reporting one
102
+ (`a2qlinux --diagnose --report`), FAQ.
102
103
  - [docs/ARCHITECTURE.md](https://github.com/raman78/A2Qlinux/blob/main/docs/ARCHITECTURE.md) — how it works and why, failure
103
104
  modes, tests, what a Questlog update can break.
104
105
 
@@ -29,7 +29,7 @@ game:
29
29
  back if they do not start.
30
30
 
31
31
  Status: in daily use on CachyOS, KDE Plasma 6 (Wayland), Proton 11
32
- (`proton-cachyos-slr`), Questlog 0.1.37. Other distributions and desktops
32
+ (`proton-cachyos-slr`), Questlog 0.1.51. Other distributions and desktops
33
33
  are untested; what they need (Steam from the distribution or Valve, not
34
34
  Flatpak; a system tray; Python 3.11 or newer; the packages per distribution)
35
35
  is in [docs/INSTALL.md](https://github.com/raman78/A2Qlinux/blob/main/docs/INSTALL.md#what-you-need-before-you-start).
@@ -48,7 +48,7 @@ for Arch, Debian, Ubuntu, Fedora and openSUSE. In short:
48
48
  everything else and prints the command for anything still missing — see
49
49
  [Installing A2Qlinux and Questlog](https://github.com/raman78/A2Qlinux/blob/main/docs/INSTALL.md#installing-a2qlinux-and-questlog).
50
50
  4. Start **Questlog (AION 2)** from the menu, or set the Steam launch option
51
- that `a2qlinux-setup` prints.
51
+ that `a2qlinux-setup` prints (it says when the option is already set).
52
52
 
53
53
  ## Documentation
54
54
 
@@ -56,7 +56,8 @@ for Arch, Debian, Ubuntu, Fedora and openSUSE. In short:
56
56
  - [docs/USING.md](https://github.com/raman78/A2Qlinux/blob/main/docs/USING.md) — starting, tray icon, playing.
57
57
  - [docs/UPDATING.md](https://github.com/raman78/A2Qlinux/blob/main/docs/UPDATING.md) — Questlog updates, installing Questlog
58
58
  by hand, and updating A2Qlinux itself (`pipx upgrade a2qlinux`).
59
- - [docs/TROUBLESHOOTING.md](https://github.com/raman78/A2Qlinux/blob/main/docs/TROUBLESHOOTING.md) — problems, FAQ.
59
+ - [docs/TROUBLESHOOTING.md](https://github.com/raman78/A2Qlinux/blob/main/docs/TROUBLESHOOTING.md) — problems, reporting one
60
+ (`a2qlinux --diagnose --report`), FAQ.
60
61
  - [docs/ARCHITECTURE.md](https://github.com/raman78/A2Qlinux/blob/main/docs/ARCHITECTURE.md) — how it works and why, failure
61
62
  modes, tests, what a Questlog update can break.
62
63
 
@@ -0,0 +1,30 @@
1
+ """A2Qlinux: Questlog Desktop for AION 2 on Linux under Proton, with live game traffic."""
2
+
3
+ try:
4
+ from ._version import __version__
5
+ except ImportError: # a source checkout that was never built or installed
6
+ __version__ = "0+unknown"
7
+
8
+
9
+ def shown_version(root=None):
10
+ """The version to show people: the built one, or in a git checkout what git says.
11
+
12
+ An editable install (`pipx install --editable .`) writes _version.py once,
13
+ at install time, and never again, so in a checkout that number goes stale
14
+ with the next commit or tag. There `git describe` is asked instead; when
15
+ that fails, the built number is shown together with the reason.
16
+ """
17
+ from pathlib import Path
18
+ import subprocess
19
+ root = Path(__file__).resolve().parent.parent if root is None else Path(root)
20
+ if not (root / ".git").exists():
21
+ return __version__
22
+ try:
23
+ done = subprocess.run(["git", "describe", "--tags", "--dirty"], cwd=root, stdin=subprocess.DEVNULL,
24
+ capture_output=True, text=True, timeout=5)
25
+ except (OSError, subprocess.TimeoutExpired) as error:
26
+ return f"{__version__} (source checkout; git describe failed: {error})"
27
+ if done.returncode != 0:
28
+ reason = (done.stderr.strip().splitlines() or [f"exit code {done.returncode}"])[0]
29
+ return f"{__version__} (source checkout; git describe failed: {reason})"
30
+ return f"{done.stdout.strip().removeprefix('v')} (source checkout)"
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '0.4.0'
22
- __version_tuple__ = version_tuple = (0, 4, 0)
21
+ __version__ = version = '0.5.0'
22
+ __version_tuple__ = version_tuple = (0, 5, 0)
23
23
 
24
24
  __commit_id__ = commit_id = None
@@ -108,6 +108,13 @@ def notify(text):
108
108
 
109
109
 
110
110
  def main():
111
+ if "--version" in sys.argv[1:]: # answered here: passed on, it would open a terminal window
112
+ from . import shown_version
113
+ print(f"A2Qlinux {shown_version()}")
114
+ return 0
115
+ if "--diagnose" in sys.argv[1:]: # read only; answered here like --version
116
+ from .diagnose import main as diagnose
117
+ return diagnose(sys.argv[1:])
111
118
  try:
112
119
  from .setup_desktop import refresh_entries
113
120
  refresh_entries(lambda text: print(f"a2qlinux: {text}", file=sys.stderr))
@@ -0,0 +1,405 @@
1
+ """a2qlinux --diagnose [--report]: what A2Qlinux needs, and how the game is started.
2
+
3
+ Read only: it changes nothing, so it is safe at any time, the game running or
4
+ not. Each check gives one line: fine, a note, or a problem with what to do.
5
+
6
+ 1. A2Qlinux's version, the settings file, Questlog's folder and version.
7
+ 2. The checks a2qlinux-setup makes: programs, capture permission, the tray
8
+ icon, the Windows parts (the same functions, a2qlinux.setup_desktop).
9
+ 3. Steam: a native installation, the game's prefix, our wpcap.dll in it.
10
+ 4. AION 2's Steam launch option, read from each Steam account's
11
+ localconfig.vdf, and whether it ever ran (steam_launch.log).
12
+ 5. What runs now: the launcher, Questlog (fed by the bridge or not), the game.
13
+ 6. On KDE Plasma 6, whether the KDE overlays are set up.
14
+
15
+ With --report it also writes a report file: the diagnosis and the end of
16
+ launcher.log, with the home folder, user name, Steam account numbers and
17
+ network addresses replaced (anonymise). It shows the report and, if the
18
+ user agrees, opens a new GitHub issue in the browser with the report filled
19
+ in; the user reviews it and submits it with their own account. Nothing is
20
+ sent by this program.
21
+ """
22
+
23
+ import ipaddress
24
+ import os
25
+ from pathlib import Path
26
+ import re
27
+ import shutil
28
+ import socket
29
+ import subprocess
30
+ import sys
31
+ import time
32
+ import urllib.parse
33
+
34
+ from . import config, shown_version
35
+
36
+ OK, NOTE, PROBLEM = "ok", "note", "PROBLEM"
37
+ ISSUES_NEW = "https://github.com/raman78/A2Qlinux/issues/new"
38
+ # Longest new-issue URL GitHub took, measured 2026-11-10 without being logged
39
+ # in (6500 characters went to the login page, 7000 gave an error 500, since
40
+ # the login page carries the whole URL along); some margin below that.
41
+ ISSUE_URL_LIMIT = 6000
42
+ REPORT_LOG_LINES = 400 # lines of launcher.log in the report file: the last few runs
43
+
44
+
45
+ # ---------------------------------------------------------------- Steam's files
46
+
47
+ def parse_vdf(text):
48
+ """Steam's text KeyValues (localconfig.vdf, libraryfolders.vdf) as nested dicts, keys lower-cased.
49
+
50
+ Steam writes keys in varying case ("apps", "Apps"), so lookups use lower
51
+ case. A file cut short gives what was read up to there.
52
+ """
53
+ tokens = re.findall(r'"((?:[^"\\]|\\.)*)"|([{}])', text)
54
+ root, stack, key = {}, [], None
55
+ current = root
56
+ for quoted, brace in tokens:
57
+ if brace == "{":
58
+ child = {}
59
+ current[(key or "").lower()] = child
60
+ stack.append(current)
61
+ current, key = child, None
62
+ elif brace == "}":
63
+ if not stack:
64
+ break
65
+ current, key = stack.pop(), None
66
+ elif key is None:
67
+ key = quoted
68
+ else:
69
+ current[key.lower()] = quoted.replace('\\"', '"').replace("\\\\", "\\")
70
+ key = None
71
+ return root
72
+
73
+
74
+ def launch_options(roots, appid):
75
+ """[(account folder, launch option or None)] for every Steam account in these installations."""
76
+ found, seen = [], set()
77
+ for root in roots:
78
+ for local in sorted(Path(root).glob("userdata/*/config/localconfig.vdf")):
79
+ account = local.parent.parent
80
+ if account.resolve() in seen:
81
+ continue
82
+ seen.add(account.resolve())
83
+ try:
84
+ tree = parse_vdf(local.read_text(encoding="utf-8", errors="replace"))
85
+ except OSError:
86
+ found.append((account, None))
87
+ continue
88
+ node = tree
89
+ for key in ("userlocalconfigstore", "software", "valve", "steam", "apps", str(appid)):
90
+ node = node.get(key, {}) if isinstance(node, dict) else {}
91
+ option = node.get("launchoptions") if isinstance(node, dict) else None
92
+ found.append((account, option or None))
93
+ return found
94
+
95
+
96
+ def judge_launch_option(option, ours):
97
+ """(level, text) for one account's launch option; `ours` is this installation's a2qlinux-steam."""
98
+ set_it = f"set it to: {ours} %command%"
99
+ if not option:
100
+ return NOTE, ("not set. The game still starts: A2Qlinux closes Questlog while Steam starts it and "
101
+ f"opens it again after, which can fail on some systems. To start Questlog with the game, {set_it}")
102
+ words = option.split()
103
+ named = [w for w in words if Path(w).name == "a2qlinux-steam"]
104
+ if not named:
105
+ return NOTE, f"set to something else ({option!r}), without a2qlinux-steam; {set_it}, keeping what is there"
106
+ if "%command%" not in words:
107
+ return PROBLEM, f"{option!r} has no %command%, so Steam never starts the game; {set_it}"
108
+ wrapper = named[0]
109
+ if "/" not in wrapper:
110
+ return PROBLEM, f"{option!r} names a2qlinux-steam without its folder, which Steam cannot find; {set_it}"
111
+ if not Path(wrapper).exists():
112
+ return PROBLEM, f"{option!r} points at {wrapper}, which does not exist (moved or uninstalled?); {set_it}"
113
+ try:
114
+ same = Path(wrapper).resolve() == Path(ours).resolve()
115
+ except OSError:
116
+ same = False
117
+ if not same:
118
+ return NOTE, f"{option!r} runs {wrapper}, not this installation's {ours}"
119
+ return OK, option
120
+
121
+
122
+ # ---------------------------------------------------------------- checks
123
+
124
+ def check_setup(results):
125
+ from . import setup_desktop as setup
126
+ info = setup.os_release()
127
+ missing, wanted = setup.missing_packages()
128
+ commands = setup.install_commands(wanted, info)
129
+ if missing or commands:
130
+ results.append((PROBLEM, "Programs: missing " + "; ".join(missing or ["a library"])
131
+ + "".join(f" - install with: {line}" for line in commands)))
132
+ else:
133
+ results.append((OK, "Programs: all there"))
134
+ capture = setup.capture_problem(info)
135
+ results.append((PROBLEM, f"Capture: {capture}") if capture else (OK, "Capture: allowed"))
136
+ tray = setup.tray_problem()
137
+ results.append((PROBLEM, f"Tray icon: {tray}") if tray else (OK, "Tray icon: can run"))
138
+ parts = setup.windows_parts_problem()
139
+ results.append((PROBLEM, f"Windows parts: {parts}") if parts else (OK, "Windows parts: present"))
140
+
141
+
142
+ def check_steam(results, appid, qdir):
143
+ from . import launcher
144
+ from .setup_desktop import command
145
+ roots = launcher.steam_roots()
146
+ if roots:
147
+ results.append((OK, "Steam: " + ", ".join(map(str, roots))))
148
+ elif launcher.FLATPAK_STEAM.is_dir():
149
+ results.append((PROBLEM, "Steam: only a Flatpak Steam was found; A2Qlinux needs Steam from the "
150
+ "distribution or from Valve (docs/INSTALL.md)"))
151
+ else:
152
+ results.append((PROBLEM, "Steam: no installation found"))
153
+ try:
154
+ prefix = launcher.game_prefix(appid, roots)
155
+ results.append((OK, f"Game prefix: {prefix}"))
156
+ dll = prefix / "drive_c" / "windows" / "system32" / "Npcap" / "wpcap.dll"
157
+ try:
158
+ ours = launcher.BRIDGE_SIGNATURE in dll.read_bytes()
159
+ results.append((OK, "wpcap.dll in the prefix: A2Qlinux's") if ours else
160
+ (PROBLEM, f"wpcap.dll in the prefix: {dll} is not A2Qlinux's (a real Npcap?); "
161
+ "the launcher leaves it alone and Questlog gets no traffic"))
162
+ except FileNotFoundError:
163
+ results.append((NOTE, "wpcap.dll in the prefix: not there yet; the launcher puts it there on start"))
164
+ except RuntimeError as error:
165
+ results.append((PROBLEM, f"Game prefix: {error}"))
166
+
167
+ try:
168
+ ours = command("a2qlinux-steam")
169
+ except RuntimeError as error:
170
+ results.append((PROBLEM, f"Launch option: {error}"))
171
+ ours = "a2qlinux-steam"
172
+ accounts = launch_options(roots, appid)
173
+ if not accounts:
174
+ results.append((NOTE, "Launch option: no Steam account's settings found (Steam not used yet?)"))
175
+ for account, option in accounts:
176
+ level, text = judge_launch_option(option, ours)
177
+ label = "Launch option" + (f" ({account})" if len(accounts) > 1 else "")
178
+ results.append((level, f"{label}: {text}"))
179
+
180
+ runs = qdir / "proton-stream" / "steam_launch.log"
181
+ try:
182
+ last = runs.read_text(errors="replace").strip().splitlines()[-1]
183
+ level = NOTE if "not running" in last else OK
184
+ results.append((level, f"Launch option last ran: {last}"))
185
+ except (FileNotFoundError, IndexError):
186
+ results.append((NOTE, "Launch option last ran: never (no steam_launch.log)"))
187
+ except OSError as error:
188
+ results.append((NOTE, f"Launch option last ran: {runs} unreadable: {error}"))
189
+
190
+
191
+ def check_running(results, appid):
192
+ from . import launcher
193
+ from .desktop import launcher_pid, launcher_running
194
+ running = launcher_running()
195
+ pid = launcher_pid()
196
+ procs = launcher.game_processes(appid, ["questlog.exe", "aion2.exe"])
197
+ questlog, game = procs["questlog.exe"], procs["aion2.exe"]
198
+ results.append((OK, f"Now: A2Qlinux is running (launcher PID {pid})" if running else "Now: A2Qlinux is not running"))
199
+ if questlog:
200
+ fed = any("QUESTLOG_PROTON_BRIDGE=" in launcher._read(f"/proc/{p}/environ") for p in questlog)
201
+ if not fed:
202
+ results.append((PROBLEM, "Now: Questlog runs, but was not started by A2Qlinux: it gets no game "
203
+ "traffic, and the game waits until it is closed. Quit it from its own tray "
204
+ "icon and start 'Questlog (AION 2)' from the menu"))
205
+ elif not running:
206
+ results.append((PROBLEM, "Now: Questlog runs with the bridge, but A2Qlinux has ended (status "
207
+ "window closed?): it gets no game traffic. Quit it and start it again"))
208
+ else:
209
+ results.append((OK, "Now: Questlog runs under A2Qlinux"))
210
+ else:
211
+ results.append((OK, "Now: Questlog is not running"))
212
+ results.append((OK, "Now: AION 2 is running" if game else "Now: AION 2 is not running"))
213
+
214
+
215
+ def check_kde(results):
216
+ from . import kde_overlays
217
+ if not kde_overlays.plasma6():
218
+ return
219
+ if kde_overlays.installed():
220
+ results.append((OK, "KDE overlays: set up"))
221
+ else:
222
+ results.append((NOTE, "KDE overlays: not set up; Black Market Cards stays hidden behind the game "
223
+ "(a2qlinux-setup --kde-overlays)"))
224
+
225
+
226
+ def diagnose(appid=3393110):
227
+ """[(level, text)], in the order of the module docstring."""
228
+ settings, problems = config.load()
229
+ qdir = settings.questlog_dir.expanduser()
230
+ results = [(OK, f"A2Qlinux {shown_version()}"), (OK, f"Settings: {config.CONFIG_PATH}")]
231
+ results += [(PROBLEM, f"Settings: {p}") for p in problems]
232
+ if (qdir / "Questlog.exe").is_file():
233
+ from .update import installed_version
234
+ results.append((OK, f"Questlog: {installed_version(qdir) or 'version unreadable'} in {qdir}"))
235
+ else:
236
+ results.append((PROBLEM, f"Questlog: no Questlog.exe in {qdir}; run a2qlinux-setup"))
237
+ for check in (check_setup, lambda r: check_steam(r, appid, qdir), lambda r: check_running(r, appid), check_kde):
238
+ try:
239
+ check(results)
240
+ except Exception as error: # one broken check must not hide the others; it is reported
241
+ results.append((PROBLEM, f"This check failed: {error!r} (please report it)"))
242
+ return results, qdir
243
+
244
+
245
+ def format_results(results):
246
+ width = max(len(level) for level, _ in results)
247
+ return "\n".join(f"{level:<{width}} {text}" for level, text in results)
248
+
249
+
250
+ # ---------------------------------------------------------------- anonymising
251
+
252
+ class Anonymiser:
253
+ """Replaces what identifies the user or their network, the same value always the same way.
254
+
255
+ Home folder -> ~, the user name as a path component -> <user>, Steam
256
+ account folders -> userdata/<steam-id-N>, the host name -> <host>,
257
+ IPv4 and IPv6 addresses -> <private-N> / <public-N> / <ipv6-N> (loopback
258
+ and 0.0.0.0 stay, they say nothing about anyone). A consistent
259
+ placeholder keeps the report readable: "the game uses <private-2>" still
260
+ matches the line where <private-2> was captured on.
261
+ """
262
+
263
+ IPV4 = re.compile(r"(?<![\d.])(\d{1,3}(?:\.\d{1,3}){3})(?!\d|\.\d)") # a full stop after it ends a sentence
264
+ # Home and VPN networks (RFC 1918, carrier-grade NAT as Tailscale uses, link-local); anything else is public.
265
+ PRIVATE = [ipaddress.ip_network(n) for n in ("10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16",
266
+ "100.64.0.0/10", "169.254.0.0/16")]
267
+ IPV6 = re.compile(r"(?<![0-9A-Fa-f:])((?:[0-9A-Fa-f]{0,4}:){2,7}[0-9A-Fa-f]{0,4})(?![0-9A-Fa-f:])")
268
+ STEAM_ID = re.compile(r"(userdata/)(\d+)")
269
+
270
+ def __init__(self, home=None, user=None, host=None):
271
+ self.home = str(home or Path.home())
272
+ self.user = user or os.environ.get("USER") or Path(self.home).name
273
+ self.host = host if host is not None else socket.gethostname()
274
+ self.names = {}
275
+
276
+ def _name(self, kind, value):
277
+ key = (kind, value)
278
+ if key not in self.names:
279
+ self.names[key] = f"<{kind}-{sum(1 for k, _ in self.names if k == kind) + 1}>"
280
+ return self.names[key]
281
+
282
+ def _ipv4(self, match):
283
+ try:
284
+ address = ipaddress.ip_address(match.group(1))
285
+ except ValueError:
286
+ return match.group(0)
287
+ if address.is_loopback or address.is_unspecified:
288
+ return match.group(0)
289
+ private = any(address in network for network in self.PRIVATE)
290
+ return self._name("private" if private else "public", str(address))
291
+
292
+ def _ipv6(self, match):
293
+ try:
294
+ address = ipaddress.ip_address(match.group(1))
295
+ except ValueError:
296
+ return match.group(0)
297
+ if address.is_loopback or address.is_unspecified:
298
+ return match.group(0)
299
+ return self._name("ipv6", str(address))
300
+
301
+ def __call__(self, text):
302
+ for home in {self.home, os.path.realpath(self.home)}:
303
+ text = text.replace(home, "~")
304
+ if self.user:
305
+ text = re.sub(rf"(?<=/){re.escape(self.user)}(?=/|\b)", "<user>", text)
306
+ text = self.STEAM_ID.sub(lambda m: m.group(1) + self._name("steam-id", m.group(2)), text)
307
+ if self.host and len(self.host) >= 3:
308
+ text = re.sub(rf"\b{re.escape(self.host)}\b", "<host>", text)
309
+ text = self.IPV4.sub(self._ipv4, text)
310
+ return self.IPV6.sub(self._ipv6, text)
311
+
312
+
313
+ # ---------------------------------------------------------------- report
314
+
315
+ def log_tail(path, lines):
316
+ try:
317
+ return path.read_text(errors="replace").splitlines()[-lines:]
318
+ except OSError:
319
+ return []
320
+
321
+
322
+ def build_report(results, qdir, anonymise):
323
+ logs = qdir / "proton-stream"
324
+ launcher_lines = log_tail(logs / "launcher.log", REPORT_LOG_LINES)
325
+ parts = [f"A2Qlinux report, {time.strftime('%Y-%m-%d %H:%M %Z')}", "", "## Diagnosis", "",
326
+ format_results(results), "", f"## launcher.log (last {REPORT_LOG_LINES} lines)", ""]
327
+ parts += launcher_lines or ["(no launcher.log yet)"]
328
+ parts += ["", "## steam_launch.log (last 10 lines)", ""]
329
+ parts += log_tail(logs / "steam_launch.log", 10) or ["(none)"]
330
+ return anonymise("\n".join(parts) + "\n")
331
+
332
+
333
+ def issue_url(results, report, report_path, anonymise, limit=ISSUE_URL_LIMIT):
334
+ """A new-issue URL with the diagnosis and as much of the log's end as fits within `limit`."""
335
+ title = f"Problem report (A2Qlinux {shown_version()})"
336
+ diagnosis = anonymise(format_results(results)).splitlines()
337
+ log_lines = report.split("## launcher.log", 1)[-1].split("## steam_launch.log", 1)[0].strip().splitlines()[1:]
338
+ log_lines = [line for line in log_lines if line.strip()]
339
+
340
+ def head(lines):
341
+ cut = "" if len(lines) == len(diagnosis) else "(cut here; the rest is in the attached report)\n"
342
+ return ("**What happened, and roughly when:**\n\n\n\n"
343
+ f"**Full report:** please attach `{anonymise(str(report_path))}` (drag it into this box).\n\n"
344
+ "### Diagnosis\n\n```\n" + "".join(f"{line}\n" for line in lines) + cut + "```\n")
345
+
346
+ def url(body):
347
+ return ISSUES_NEW + "?" + urllib.parse.urlencode({"title": title, "body": body})
348
+
349
+ full = head(diagnosis)
350
+ for keep in range(len(log_lines), 0, -1): # as much of the log's end as fits
351
+ candidate = (full + f"\n### launcher.log (last {keep} lines)\n\n```\n"
352
+ + "\n".join(log_lines[-keep:]) + "\n```\n")
353
+ if len(url(candidate)) <= limit:
354
+ return url(candidate)
355
+ lines = list(diagnosis) # no log line fits: the diagnosis, shortened if need be
356
+ while lines and len(url(head(lines))) > limit:
357
+ lines.pop()
358
+ return url(head(lines))
359
+
360
+
361
+ def report(results, qdir, ask=input, interactive=None, opener=None):
362
+ interactive = sys.stdin.isatty() if interactive is None else interactive
363
+ anonymise = Anonymiser()
364
+ text = build_report(results, qdir, anonymise)
365
+ path = Path.home() / f"a2qlinux-report-{time.strftime('%Y%m%d-%H%M%S')}.txt"
366
+ path.write_text(text)
367
+ print("\n" + text)
368
+ print(f"Report written to {path}.\nHome folder, user name, host name, Steam account numbers and network "
369
+ "addresses are replaced; read it above before you share it.")
370
+ if not interactive:
371
+ print(f"To report a problem, open {ISSUES_NEW} and attach that file.")
372
+ return 0
373
+ answer = ask("\nOpen a new GitHub issue in your browser with this report? It will be public. [y/N] ")
374
+ if answer.strip().lower() not in ("y", "yes"):
375
+ print(f"Not opened. To report later, open {ISSUES_NEW} and attach {path}.")
376
+ return 0
377
+ url = issue_url(results, text, path, anonymise)
378
+ opener = opener or open_in_browser
379
+ if not opener(url):
380
+ print(f"No browser could be started. Open this address yourself:\n{url}")
381
+ else:
382
+ print(f"Opened in your browser. Log in, attach {path}, describe what happened, then submit.")
383
+ return 0
384
+
385
+
386
+ def open_in_browser(url):
387
+ found = shutil.which("xdg-open")
388
+ if not found:
389
+ return False
390
+ try:
391
+ subprocess.Popen([found, url], stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
392
+ stderr=subprocess.DEVNULL, start_new_session=True)
393
+ except OSError:
394
+ return False
395
+ return True
396
+
397
+
398
+ def main(argv):
399
+ results, qdir = diagnose()
400
+ print(format_results(results))
401
+ problems = sum(1 for level, _ in results if level == PROBLEM)
402
+ print(f"\n{problems} problem(s)." if problems else "\nNo problems found.")
403
+ if "--report" in argv:
404
+ report(results, qdir)
405
+ return 1 if problems else 0