Forráskód Böngészése

Fix init-db call and circular dep.

scossu 8 hónapja
szülő
commit
f0377ae91d
2 módosított fájl, 10 hozzáadás és 4 törlés
  1. 1 1
      entrypoint.sh
  2. 9 3
      scriptshifter/tables/__init__.py

+ 1 - 1
entrypoint.sh

@@ -12,7 +12,7 @@ fi
 host=${TXL_WEBAPP_HOST:-"0.0.0.0"}
 port=${TXL_WEBAPP_PORT:-"8000"}
 
-./sscli admin init--db
+./sscli admin init-db
 
 if [ "${FLASK_ENV}" == "development" ]; then
     exec flask run -h $host -p $port

+ 9 - 3
scriptshifter/tables/__init__.py

@@ -151,8 +151,12 @@ def init_db():
     """
     # Create parent diretories if necessary.
     # If the DB already exists, it will be overwritten ONLY on success at
-    # thhis point.
-    makedirs(path.dirname(TMP_DB_PATH), exist_ok=True)
+    # hhis point.
+    if path.isfile(TMP_DB_PATH):
+        # Remove previous temp file (possibly from failed attempt)
+        unlink(TMP_DB_PATH)
+    else:
+        makedirs(path.dirname(TMP_DB_PATH), exist_ok=True)
 
     conn = sqlite3.connect(TMP_DB_PATH)
 
@@ -162,9 +166,11 @@ def init_db():
             conn.executescript(fh.read())
 
     # Populate tables.
+    with open(path.join(TABLE_DIR, "index.yml")) as fh:
+        tlist = load(fh, Loader=Loader)
     try:
         with conn:
-            for tname, tdata in list_tables().items():
+            for tname, tdata in tlist.items():
                 res = conn.execute(
                     """INSERT INTO tbl_language (
                         name, label, marc_code, description