소스 검색

web: create remotes.json if it doesn't exist

Shiv Tyagi 1 년 전
부모
커밋
b36886922f
1개의 변경된 파일21개의 추가작업 그리고 0개의 파일을 삭제
  1. 21 0
      web/wsgi.py

+ 21 - 0
web/wsgi.py

@@ -3,6 +3,27 @@
 import logging
 import sys
 import os
+
+cbs_basedir = os.environ.get('CBS_BASEDIR')
+
+if cbs_basedir:
+    # Ensure base subdirectories exist
+    os.makedirs(os.path.join(cbs_basedir, 'builds'), exist_ok=True)
+    os.makedirs(os.path.join(cbs_basedir, 'configs'), exist_ok=True)
+
+    # Ensure remotes.json exists
+    remotes_json_path = os.path.join(cbs_basedir, 'configs', 'remotes.json')
+    if not os.path.isfile(remotes_json_path):
+        print("Creating remotes.json...")
+        from scripts import fetch_releases
+        fetch_releases.run(
+            base_dir=os.path.join(
+                os.path.dirname(remotes_json_path),
+                '..',
+            ),
+            remote_name="ardupilot",
+        )
+
 logging.basicConfig(stream=sys.stderr)
 sys.path.insert(0, os.path.dirname(__file__))
 from app import app as application