v0.1.0: version in the status bar + one-click self-update via git pull
__version__ in lintunes/__init__.py (setup.py regex-reads it) shows bottom-left via the new VersionButton; the tooltip carries the git short hash so machines on the same version but different commits are distinguishable. The new Updater fetches upstream 10s after launch and every 4h on daemon threads (lastfm.py pattern); commits behind put a * on the button, and clicking it confirms, runs `git pull --ff-only`, quits cleanly (library flush + player shutdown), and re-execs `python -m lintunes.main` on the new code. Positional file args are stripped from the re-exec so they don't re-import as duplicates. Pull failures surface the git error: line in the status bar and leave the running app untouched; outside a git checkout the button is a plain label. Also fixes a Round-5 regression found while verifying: the totals label was a permanent status-bar widget with stretch=1, which squeezed the transient-message area to zero width — every showMessage (scrobbles, tag-write errors, import status) has been invisible since. Both readouts are now non-permanent widgets, so a transient message temporarily replaces them and they return.
This commit is contained in:
+16
-3
@@ -1,4 +1,5 @@
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
@@ -58,7 +59,15 @@ def main():
|
||||
if args.import_file:
|
||||
run_import(Path(args.import_file), music_root, data_dir)
|
||||
else:
|
||||
run_gui(data_dir, [Path(f) for f in args.files], qt_args)
|
||||
if run_gui(data_dir, [Path(f) for f in args.files], qt_args):
|
||||
# A self-update just pulled new code; replace this process with a
|
||||
# fresh launch running the updated source. -m works whether we
|
||||
# started as `lintunes` or `python -m lintunes.main`. Positional
|
||||
# files are dropped — they were imported on the first launch and
|
||||
# would be re-imported (duplicated) on every restart otherwise.
|
||||
argv = [a for a in sys.argv[1:] if a not in args.files]
|
||||
os.execv(sys.executable,
|
||||
[sys.executable, "-m", "lintunes.main", *argv])
|
||||
|
||||
|
||||
def run_import(xml_path: Path, music_root: str | None, data_dir: Path):
|
||||
@@ -93,7 +102,8 @@ def run_import(xml_path: Path, music_root: str | None, data_dir: Path):
|
||||
print("Import complete!")
|
||||
|
||||
|
||||
def run_gui(data_dir: Path, files: list[Path], qt_args: list[str] | None = None):
|
||||
def run_gui(data_dir: Path, files: list[Path],
|
||||
qt_args: list[str] | None = None) -> bool:
|
||||
import logging
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
@@ -147,7 +157,10 @@ def run_gui(data_dir: Path, files: list[Path], qt_args: list[str] | None = None)
|
||||
window.show_conflict_summary(startup_conflicts)
|
||||
if files:
|
||||
window.import_files(files)
|
||||
sys.exit(app.exec())
|
||||
exit_code = app.exec()
|
||||
if window.restart_requested:
|
||||
return True # caller re-execs the updated code
|
||||
sys.exit(exit_code)
|
||||
|
||||
|
||||
def _ensure_now_playing_font(prefs):
|
||||
|
||||
Reference in New Issue
Block a user