Files
HBlink4/run_dashboard.py
cortandClaude Opus 5 f1a2e4133c Make the module files directly runnable again; no install step
The previous commit required "pip install -e ." before anything would
run, and made "python hblink4/hblink.py" fail outright. That trades a
real support burden -- an install step people forget after git pull, and
an error message that looks like a broken checkout -- for an internal
correctness property. Not a good trade for this project's users, who have
run hblink by interpreter-plus-path since HBlink3 and DMRlink.

Establish the package context explicitly instead. When hblink4/hblink.py
or dashboard/server.py is run by path, __package__ is empty, so each now
puts the project root on sys.path and sets __package__ before its
relative imports. That is enough for "from .constants import ..." to
resolve to hblink4.constants -- one copy, not the two the old
except-ImportError fallback produced. Importing the parent package is
cheap because __init__.py is metadata only.

Every invocation style now works and none of them double-load:

  python hblink4/hblink.py config/config.json      <- systemd uses this
  python dashboard/server.py                       <- systemd uses this
  python run_hblink.py config/config.json          <- convenience
  python run_dashboard.py                          <- convenience
  python -m hblink4.hblink
  hblink4                                          <- if pip installed

The systemd units invoke the module files directly rather than going
through a launcher, so there is one less moving part between systemd and
the program. run_hblink.py and run_dashboard.py stay in the project root
as launchers for interactive use, but they are now genuinely logic-free:
the uvicorn call that used to live in run_dashboard.py is dashboard.server.run().

requirements.txt and requirements-dashboard.txt come back as the
documented install path. pyproject.toml stays for those who want
"pip install -e .", but is now optional and reads its dependencies from
those files so the two cannot drift.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-06 20:54:37 -05:00

21 lines
541 B
Python
Executable File

#!/usr/bin/env python3
"""
Convenience launcher for the HBlink4 dashboard.
python run_dashboard.py [bind] [port]
Purely a shortcut for interactive use -- it contains no logic beyond locating
dashboard/server.py, which is equally runnable on its own:
python dashboard/server.py [bind] [port]
The systemd unit uses that direct path rather than this script. With no
arguments the bind address and port come from the 'web' section of
dashboard/config.json.
"""
from dashboard.server import run
if __name__ == '__main__':
run()