Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

All notable changes to QuickPRS will be documented in this file.

## [1.1.0] - 2026-10-27
## [1.1.0] - 2026-10-28

### Fixed
- **Edits broke the file structure RPM reads.** A .PRS file is an MFC archive: every class and object is numbered as it is written, and every list starts with its count. Adding or removing a talkgroup, channel, set or system left every later class tag and the list counts stale, and MFC's loader, which RPM uses, rejects tags that name the wrong class. QuickPRS now reads a personality into a tree that keeps every byte and writes it back with tags and counts recomputed. All 36 RPM-saved test files re-serialize byte for byte. See [docs/prs-format.md](docs/prs-format.md).
Expand All @@ -27,6 +27,8 @@ All notable changes to QuickPRS will be documented in this file.
- `set-option` accepted misspelt attributes and values a field does not allow, and wrote nested settings on the parent element; the default options XML is now RPM's own; presets and profiles no longer set attributes the XG-100P does not have
- GUI: crashed on start; the Import Wizard failed every non-talkgroup import; the System Wizard reported failure on success and could add a system twice; undo history carried over to the next file; opening a recent file did not ask about unsaved changes; Delete, F2 and undo acted on the tree while typing; multi-select edits touched talkgroups that were not selected; Health Check crashed; dropped paths were not read as Unicode
- `search` skipped unreadable files without saying so; listings print 6.25 kHz channels with 5 decimals
- The standalone EXE is a windowed program, so its commands printed nothing in a console; releases now include `QuickPRS-cli.exe`, a console build for the command line
- Classic Windows console windows showed color codes as text (`←[1m`); QuickPRS now turns on their handling, leaves colors out where it cannot, and honors `NO_COLOR`

### Added
- `quickprs radio`: groundwork for reading the radio over Bluetooth. The XG-100P uses Bluetooth Classic (serial port profile), which RPM programs over like the USB cable. `scan` finds paired radios and their COM ports, `probe` listens, `relay` sits between RPM and the radio and logs both directions, and `analyze` summarises a capture and extracts any personality in it. None of them sends bytes of its own to the radio. See [docs/bluetooth.md](docs/bluetooth.md).
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ python -m quickprs # Launch GUI
python -m quickprs --help # CLI help
```

Or use the standalone EXE from [Releases](../../releases) (no Python required).
Or use the standalone EXEs from [Releases](../../releases) (no Python required): `QuickPRS.exe` is the GUI, and `QuickPRS-cli.exe` runs the commands below from a console, for example `QuickPRS-cli.exe validate radio.PRS`.

### Optional dependencies:

Expand Down
67 changes: 46 additions & 21 deletions build.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
"""Build QuickPRS standalone executable using PyInstaller.
"""Build QuickPRS standalone executables using PyInstaller.

Usage:
python build.py
python build.py [extra PyInstaller options, e.g. --workpath DIR]

Requires:
pip install pyinstaller

Output:
dist/QuickPRS.exe (single-file executable)
dist/QuickPRS.exe GUI (windowed, no console)
dist/QuickPRS-cli.exe command line (console)
"""

import os
Expand All @@ -17,6 +18,13 @@

ROOT = Path(__file__).parent

# (name, windowed). A console does not wait for a windowed program or show
# its output, so the command line needs its own console build.
EXECUTABLES = (
("QuickPRS", True),
("QuickPRS-cli", False),
)


def get_version():
"""Read version from quickprs/__init__.py."""
Expand All @@ -27,17 +35,16 @@ def get_version():
return "0.0.0"


def build():
version = get_version()

def pyinstaller_cmd(name, windowed, extra=()):
"""The PyInstaller command line for one executable."""
# Windows uses ';' as path separator for --add-data, Unix uses ':'
sep = ';' if os.name == 'nt' else ':'

cmd = [
return [
sys.executable, "-m", "PyInstaller",
"--onefile",
"--windowed",
"--name", "QuickPRS",
"--windowed" if windowed else "--console",
"--name", name,
"--add-data", f"{ROOT / 'quickprs'}{sep}quickprs",
# Every quickprs module, so new ones need no list to keep
"--collect-submodules", "quickprs",
Expand All @@ -52,26 +59,44 @@ def build():
"--hidden-import", "windnd",
"--hidden-import", "sv_ttk",
"--hidden-import", "darkdetect",
*extra,
str(ROOT / "run.py"),
]


def _dist_dir(extra):
"""Where PyInstaller puts the executables (--distpath or dist/)."""
extra = list(extra)
for i, arg in enumerate(extra):
if arg == "--distpath" and i + 1 < len(extra):
return Path(extra[i + 1])
if arg.startswith("--distpath="):
return Path(arg.split("=", 1)[1])
return ROOT / "dist"


def build(extra=()):
version = get_version()
print(f"Building QuickPRS v{version}...")
print(f"Command: {' '.join(cmd)}")
result = subprocess.run(cmd, cwd=str(ROOT))

if result.returncode == 0:
exe = ROOT / "dist" / "QuickPRS.exe"
for name, windowed in EXECUTABLES:
cmd = pyinstaller_cmd(name, windowed, extra)
print(f"Command: {' '.join(cmd)}")
result = subprocess.run(cmd, cwd=str(ROOT))
if result.returncode != 0:
print(f"\nBuild of {name} failed with return code "
f"{result.returncode}")
sys.exit(1)

print(f"\nVersion: {version}")
for name, _ in EXECUTABLES:
exe = _dist_dir(extra) / f"{name}.exe"
if exe.exists():
size_mb = exe.stat().st_size / 1024 / 1024
print(f"\nBuild successful: {exe}")
print(f"Version: {version}")
print(f"Size: {size_mb:.1f} MB")
print(f"Built: {exe} ({size_mb:.1f} MB)")
else:
print("\nBuild completed but exe not found at expected path.")
else:
print(f"\nBuild failed with return code {result.returncode}")
sys.exit(1)
print(f"Build completed but {exe} was not found.")


if __name__ == "__main__":
build()
build(sys.argv[1:])
2 changes: 1 addition & 1 deletion quickprs/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4286,7 +4286,7 @@ def run_cli(args=None):
version_str = (
f"QuickPRS v{__version__}\n"
f"Python {py_ver} on {os_label}\n"
f"50+ CLI commands | quickprs cheat-sheet for reference"
f"60+ CLI commands | quickprs cheat-sheet for reference"
)

parser = argparse.ArgumentParser(
Expand Down
49 changes: 45 additions & 4 deletions quickprs/colors.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,68 @@
"""ANSI color support for terminal output.

Provides colored text helpers that auto-detect TTY capability.
Colors are disabled when output is piped or redirected, or when
the --no-color flag is active.
Colors are disabled when output is piped or redirected, when the
--no-color flag is active or NO_COLOR is set, and in a Windows console
that cannot show them.
"""

import os
import sys

# Global flag — set True by --no-color CLI flag
_no_color = False

# Whether this Windows console shows ANSI codes (None until checked)
_windows_vt = None

ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004


def disable_color():
"""Disable all color output (called by --no-color flag)."""
global _no_color
_no_color = True


def _kernel32():
import ctypes
return ctypes.WinDLL("kernel32", use_last_error=True)


def _enable_windows_vt():
"""Turn on ANSI code handling in this Windows console.

A Windows console prints escape codes as text unless the program
turns this on (Windows 10 and later). Returns False when it cannot.
"""
global _windows_vt
if _windows_vt is None:
_windows_vt = False
try:
import ctypes
from ctypes import wintypes
k32 = _kernel32()
k32.GetStdHandle.restype = wintypes.HANDLE
handle = k32.GetStdHandle(-11) # STD_OUTPUT_HANDLE
mode = wintypes.DWORD()
if k32.GetConsoleMode(handle, ctypes.pointer(mode)):
vt = ENABLE_VIRTUAL_TERMINAL_PROCESSING
_windows_vt = bool(mode.value & vt) or bool(
k32.SetConsoleMode(handle, mode.value | vt))
except (AttributeError, OSError):
pass
return _windows_vt


def supports_color():
"""Check if stdout supports ANSI color codes."""
if _no_color:
if _no_color or os.environ.get("NO_COLOR"):
return False
if not (hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()):
return False
return hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()
if sys.platform == "win32":
return _enable_windows_vt()
return True


def _code(ansi):
Expand Down
2 changes: 1 addition & 1 deletion quickprs/gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def _build_welcome(self):

# Version info
ttk.Label(self._welcome_frame,
text=f"v{__version__} \u2022 50+ CLI commands \u2022 quickprs --help",
text=f"v{__version__} \u2022 60+ CLI commands \u2022 quickprs --help",
foreground="gray").pack(side=tk.BOTTOM, pady=10)

# Show the welcome screen initially
Expand Down
68 changes: 68 additions & 0 deletions tests/test_build_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
"""Tests for build.py: which executables a release build makes."""

import importlib.util
import subprocess
from pathlib import Path

ROOT = Path(__file__).parent.parent

_spec = importlib.util.spec_from_file_location("quickprs_build_script",
ROOT / "build.py")
build = importlib.util.module_from_spec(_spec)
_spec.loader.exec_module(build)


def _commands(monkeypatch, extra):
"""The PyInstaller command lines build() runs, without running them."""
calls = []

def fake_run(cmd, cwd=None, **kwargs):
calls.append(cmd)
return subprocess.CompletedProcess(cmd, 0)

monkeypatch.setattr(build.subprocess, "run", fake_run)
build.build(extra)
return calls


def _by_name(cmds):
return {cmd[cmd.index("--name") + 1]: cmd for cmd in cmds}


class TestExecutables:

def test_gui_and_console_builds(self, monkeypatch, tmp_path):
"""A console neither waits for the windowed GUI build nor shows its
output, so the command line gets a console build of its own."""
builds = _by_name(_commands(monkeypatch, ["--distpath", str(tmp_path)]))
assert set(builds) == {"QuickPRS", "QuickPRS-cli"}
assert "--windowed" in builds["QuickPRS"]
assert "--console" not in builds["QuickPRS"]
assert "--console" in builds["QuickPRS-cli"]
assert "--windowed" not in builds["QuickPRS-cli"]

def test_builds_bundle_the_same_modules(self, monkeypatch, tmp_path):
builds = _by_name(_commands(monkeypatch, ["--distpath", str(tmp_path)]))

def options(cmd):
cmd = [a for a in cmd if a not in ("--windowed", "--console")]
i = cmd.index("--name")
return cmd[:i] + cmd[i + 2:]

assert options(builds["QuickPRS"]) == options(builds["QuickPRS-cli"])

def test_extra_options_reach_every_build(self, monkeypatch, tmp_path):
work = str(tmp_path / "work")
cmds = _commands(monkeypatch, ["--workpath", work,
"--distpath", str(tmp_path)])
for cmd in cmds:
assert cmd[-1] == str(ROOT / "run.py")
assert cmd[cmd.index("--workpath") + 1] == work

def test_reports_where_the_executables_are(self, monkeypatch, tmp_path,
capsys):
(tmp_path / "QuickPRS.exe").write_bytes(b"x" * 2048)
_commands(monkeypatch, [f"--distpath={tmp_path}"])
out = capsys.readouterr().out
assert f"Built: {tmp_path / 'QuickPRS.exe'}" in out
assert f"{tmp_path / 'QuickPRS-cli.exe'} was not found" in out
Loading