feat: portable Windows data layout and launcher package

Separate persistent user data from application code (data/work_tracker.db,
data/uploads, data/storage) with idempotent legacy migration and SQLite
integrity checks. Add offline packaging scripts for a Windows x11 x64
portable ZIP (embeddable Python, Start/Stop/Backup.bat). Fix launcher:
no multiline python -c in BAT and no os.dup2 — uvicorn runs detached with
wvt.log; health wait and busy-port diagnostics included.
This commit is contained in:
Арсентьев Александр
2026-10-20 15:55:04 +03:00
parent a6449a7d70
commit b97d79e13a
28 changed files with 2432 additions and 11 deletions
+58
View File
@@ -0,0 +1,58 @@
"""Create a consistent backup ZIP of the data directory (SQLite + uploads + storage).
Usage: backup_data.py <data_dir> <backups_dir>
Prints the created zip path on stdout.
Exit codes: 0 ok, 1 error, 2 bad args.
"""
import shutil
import sqlite3
import sys
import tempfile
import time
import zipfile
from pathlib import Path
def main() -> int:
if len(sys.argv) != 3:
print("usage: backup_data.py <data_dir> <backups_dir>", file=sys.stderr)
return 2
data = Path(sys.argv[1])
backups = Path(sys.argv[2])
backups.mkdir(parents=True, exist_ok=True)
stamp = time.strftime("%Y%m%d-%H%M%S")
out_zip = backups / f"backup-{stamp}.zip"
stage = Path(tempfile.mkdtemp(prefix="wvt-bk-", dir=str(backups)))
try:
db = data / "work_tracker.db"
if db.is_file():
src = sqlite3.connect(db)
dst = sqlite3.connect(stage / "work_tracker.db")
try:
with dst:
src.backup(dst)
finally:
dst.close()
src.close()
for sub in ("uploads", "storage"):
s = data / sub
if s.is_dir():
shutil.copytree(s, stage / sub, dirs_exist_ok=True)
with zipfile.ZipFile(out_zip, "w", compression=zipfile.ZIP_DEFLATED) as zf:
for path in sorted(stage.rglob("*")):
if path.is_file():
zf.write(path, path.relative_to(stage).as_posix())
print(out_zip)
return 0
except Exception as exc:
print(f"ERROR {type(exc).__name__}: {exc}", file=sys.stderr)
return 1
finally:
shutil.rmtree(stage, ignore_errors=True)
if __name__ == "__main__":
raise SystemExit(main())