Make default script run with GUI if possible. Add --gui to force GUI.
This commit is contained in:
@@ -54,9 +54,30 @@ def main() -> None:
|
|||||||
action="append",
|
action="append",
|
||||||
help=(f"Endpoint (default: localhost:{DEFAULT_PORT})."),
|
help=(f"Endpoint (default: localhost:{DEFAULT_PORT})."),
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--gui",
|
||||||
|
action="store_true",
|
||||||
|
help="Run with GUI (fails if GUI dependencies are not installed)",
|
||||||
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
# --listen implies server-only mode; use --gui to force GUI even with --listen.
|
||||||
|
use_gui = args.gui or not args.listen
|
||||||
|
|
||||||
|
if use_gui:
|
||||||
|
try:
|
||||||
|
from mediahive.winmain import winmain
|
||||||
|
except ImportError as exc:
|
||||||
|
if args.gui:
|
||||||
|
raise RuntimeError(
|
||||||
|
"GUI dependencies are not installed. "
|
||||||
|
"Install with: uv pip install mediahive[gui]"
|
||||||
|
) from exc
|
||||||
|
else:
|
||||||
|
winmain()
|
||||||
|
return
|
||||||
|
|
||||||
if args.media_folders:
|
if args.media_folders:
|
||||||
roots: dict[str, str] = {}
|
roots: dict[str, str] = {}
|
||||||
for path in args.media_folders:
|
for path in args.media_folders:
|
||||||
|
|||||||
@@ -893,7 +893,7 @@ def winmain() -> None:
|
|||||||
nargs="?",
|
nargs="?",
|
||||||
help="Path to the media folder (default: saved config or initial setup dialog)",
|
help="Path to the media folder (default: saved config or initial setup dialog)",
|
||||||
)
|
)
|
||||||
args = parser.parse_args()
|
args, _unknown = parser.parse_known_args()
|
||||||
|
|
||||||
_prepend_meipass_to_path()
|
_prepend_meipass_to_path()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user