UI
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user