refactor: scenes use manifest.json (same structure as dashboards)
This commit is contained in:
+8
-8
@@ -87,9 +87,9 @@ class SceneManager:
|
||||
for item in SCENES_DIR.iterdir():
|
||||
if not item.is_dir():
|
||||
continue
|
||||
f = item / "scene.json"
|
||||
if not f.exists():
|
||||
continue
|
||||
f = item / "manifest.json"
|
||||
if not f.exists():
|
||||
continue
|
||||
try:
|
||||
with open(f, "r", encoding="utf-8") as fp:
|
||||
data = json.load(fp)
|
||||
@@ -107,7 +107,7 @@ class SceneManager:
|
||||
|
||||
def get(self, scene_id: str) -> dict[str, Any] | None:
|
||||
item = SCENES_DIR / scene_id
|
||||
f = item / "scene.json"
|
||||
f = item / "manifest.json"
|
||||
if not f.exists():
|
||||
return None
|
||||
try:
|
||||
@@ -128,7 +128,7 @@ class SceneManager:
|
||||
item = SCENES_DIR / scene.id
|
||||
item.mkdir(parents=True, exist_ok=True)
|
||||
try:
|
||||
with open(item / "scene.json", "w", encoding="utf-8") as f:
|
||||
with open(item / "manifest.json", "w", encoding="utf-8") as f:
|
||||
json.dump(scene.to_dict(), f, indent=2, ensure_ascii=False)
|
||||
logger.info("Scene saved: %s", scene.id)
|
||||
return True
|
||||
@@ -160,10 +160,10 @@ class SceneManager:
|
||||
def import_scene_zip(self, zip_data: bytes) -> bool:
|
||||
try:
|
||||
with zipfile.ZipFile(io.BytesIO(zip_data), 'r') as zf:
|
||||
if "scene.json" not in zf.namelist():
|
||||
logger.error("No scene.json found in zip")
|
||||
if "manifest.json" not in zf.namelist():
|
||||
logger.error("No manifest.json found in zip")
|
||||
return False
|
||||
data = json.loads(zf.read("scene.json").decode('utf-8'))
|
||||
data = json.loads(zf.read("manifest.json").decode('utf-8'))
|
||||
scene = Scene.from_dict(data)
|
||||
item = SCENES_DIR / scene.id
|
||||
if item.exists():
|
||||
|
||||
Reference in New Issue
Block a user