This commit is contained in:
2026-09-01 15:20:03 +02:00
parent c8b9591441
commit e274ece128
3 changed files with 544 additions and 807 deletions
+18 -1
View File
@@ -3,16 +3,33 @@
from __future__ import annotations
import os
from pathlib import Path
from a2wsgi import WSGIMiddleware
from core.loader import load_module
def _has_plans(path: Path) -> bool:
return any((path / "plans").glob("*.json"))
def _resolve_data_dir(default: Path) -> Path:
for candidate in (
Path("/home/michael/boehmitools/runtime/training/data/trainingsplan"),
Path("/home/michael/runtime/training/data/trainingsplan"),
):
if _has_plans(candidate):
return candidate.resolve()
if _has_plans(default):
return default
return default
def create_app(ctx):
# app.py liest DATA_DIR beim Import und legt dort den ersten Plan an.
previous = os.environ.get("DATA_DIR")
os.environ["DATA_DIR"] = str(ctx.data_dir)
os.environ["DATA_DIR"] = str(_resolve_data_dir(ctx.data_dir))
try:
module = load_module(ctx.path("app.py"), f"btp_{ctx.id}_app")
finally: