Repository navigation
4.1.0c
Summary
This refactor standardizes process exit semantics, ensures --check-only always
runs a check and never signals an install, and tightens error handling and
quiet/batch output across the updater suite.
Key Changes
Exit-code model (finalized):
0 = nothing to do / info-only (server-version, stats, no update, check-only)
1 = update installed (server jar updated)
2 = script upgraded (self-update installed)
3 = no internet
10 = fatal (bad Python version; file lock/permission; unexpected failure)
Behavioral changes:
Replaced all exit() calls with explicit sys.exit(N) and removed stray
spaces in calls (e.g., sys.exit () → sys.exit(0)).
--check-only is authoritative:
Always performs serv.check(...) (even if --no-check, --new, or
--interactive are also present), prints the result, then exits 0.
Never signals “update installed”.
Upgrade path:
upgrade_script(...) performs download+install of the script and exits 2
on success; if nothing to upgrade (or frozen), control returns to main and
we exit 0.
Update path:
After a successful get_new(...), exit 1.
If no update was needed, exit 0.
Hardening & UX:
Internet check tries ping up to 4 times; falls back to socket test if ping
is unavailable; on complete failure exits 3 with a clear message.
Python version gate now exits 10 on unsupported runtimes (<3.7) rather than
implicitly succeeding.
Windows file-in-use / move/delete failures during install now exit 10,
with clear instructions to stop the server process and retry.
Quiet/Batch printing passes through a filter list to keep logs clean and
suppress noise in scripted environments.
Progress bar in interactive mode is shown only when it can be meaningful
(non-batch, non-quiet, content-length known).
Seed update_available = True to keep legacy “blind install” modes working
(--new, --no-check, or interactive flows that skip check), preventing
NameError and allowing intentional “just install” runs.
Implementation Notes
Standardized sys.exit(10) for fatal conditions:
invalid Python version
file lock/permission errors on Windows delete/move
unexpected exceptions during critical IO
Info-only paths (--server-version, --stats) now exit 0 consistently.
Check-only block is placed immediately after ServerUpdater initialization so
serv.check(...) is always valid, and before any install logic.
Main flow order (simplified):
version/quiet/internet gates
optional banner
create ServerUpdater
--check-only → run check → exit 0
--upgrade/--force-upgrade → run upgrade_script (exits 2 on success) → else exit 0
serv.start()
resolve output name
info-only flags (--server-version, --stats) → exit 0
regular check (unless intentionally skipped by mode)
if update available → download/install → exit 1 else exit 0
Why this is better
Scripts and batch wrappers can rely on clean, non-overlapping exit codes.
--check-only does exactly what it says every time, regardless of other flags.
Self-upgrade signaling is precise (2 only when a new script is actually
written), eliminating false positives.
Operational errors are clearly separated from state signals, improving
diagnosability in logs and schedulers.