feat(entry): implement def main
This commit is contained in:
parent
d5fb035807
commit
dfbea5b0ac
1 changed files with 36 additions and 0 deletions
|
|
@ -123,3 +123,39 @@ def validate_x11_environment():
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
"Missing X11 runtime environment. Set DISPLAY or use --backend wayland."
|
"Missing X11 runtime environment. Set DISPLAY or use --backend wayland."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# main: function definition for ScanSlicer behavior.
|
||||||
|
def main(argv=None):
|
||||||
|
args = parse_args(sys.argv[1:] if argv is None else argv)
|
||||||
|
runtime_backend = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
runtime_backend = resolve_runtime_backend(args.backend)
|
||||||
|
configure_qt_backend(runtime_backend)
|
||||||
|
if runtime_backend == "wayland":
|
||||||
|
validate_wayland_environment()
|
||||||
|
elif runtime_backend == "x11":
|
||||||
|
validate_x11_environment()
|
||||||
|
|
||||||
|
from .main import run_app
|
||||||
|
|
||||||
|
return run_app(args.path)
|
||||||
|
except Exception as exc:
|
||||||
|
selected = os.environ.get("QT_QPA_PLATFORM", "<unset>")
|
||||||
|
print(
|
||||||
|
f"Failed to start ScanSlicer Qt UI (backend={runtime_backend or args.backend}, QT_QPA_PLATFORM={selected}).",
|
||||||
|
file=sys.stderr,
|
||||||
|
)
|
||||||
|
print(str(exc), file=sys.stderr)
|
||||||
|
if runtime_backend == "x11":
|
||||||
|
print(
|
||||||
|
"X11 hint: ensure DISPLAY is set and an X server is available.",
|
||||||
|
file=sys.stderr,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
print(
|
||||||
|
"Wayland hint: ensure XDG_RUNTIME_DIR and WAYLAND_DISPLAY are set and the Wayland socket is mounted.",
|
||||||
|
file=sys.stderr,
|
||||||
|
)
|
||||||
|
return 1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue