]> OzVa Git service - delta-velorum/commitdiff
Added DELTA_PATH envvar main
authorMax Value <greenwoodw50@gmail.com>
Wed, 13 May 2026 21:29:27 +0000 (22:29 +0100)
committerMax Value <greenwoodw50@gmail.com>
Wed, 13 May 2026 21:29:27 +0000 (22:29 +0100)
sorry guys i folded

argo/__init__.py
argo/admin.py
argo/database/__init__.py
argo/database/read.py
argo/database/utils.py
argo/database/write.py

index f3e03d624b31091ff7592d297290d3d7360e1248..02c66de4aeae95145bc440ae021ef21924738cdf 100644 (file)
@@ -9,6 +9,8 @@ import os
 from .utils import deindex
 
 STAR = os.getenv("DELTA_VELORUM", "B")
 from .utils import deindex
 
 STAR = os.getenv("DELTA_VELORUM", "B")
+PATH = os.getenv("DELTA_PATH")
+
 import argo.admin as admin
 
 from argo.database.read import read_views as database_read_views
 import argo.admin as admin
 
 from argo.database.read import read_views as database_read_views
@@ -18,9 +20,11 @@ socketio = SocketIO(app, logger=False, engineio_logger=False)
 auth = HTTPBasicAuth()
 CORS(app)
 
 auth = HTTPBasicAuth()
 CORS(app)
 
+app.root_path = f"{PATH}/argo/"
+
 # import authentication data
 
 # import authentication data
 
-with open(f"{app.root_path}/../../secrets.json", "r", encoding="utf-8") as f:
+with open(f"{PATH}/../secrets.json", "r", encoding="utf-8") as f:
        users = json.loads(f.read())
 users = {k: generate_password_hash(v) for (k, v) in users.items()}
 
        users = json.loads(f.read())
 users = {k: generate_password_hash(v) for (k, v) in users.items()}
 
@@ -61,9 +65,9 @@ app.route("/admin/<string:table_name>", methods=["get", "post"])(auth.login_requ
 
 @app.route("/script/<path:filename>", methods=["get"])
 def script(filename):
 
 @app.route("/script/<path:filename>", methods=["get"])
 def script(filename):
-       return send_from_directory(os.path.join(app.root_path, "build"), filename)
+       return send_from_directory(os.path.join(PATH, "argo", "build"), filename)
 
 @app.route("/db", methods=["get"])
 @auth.login_required
 def download_db():
 
 @app.route("/db", methods=["get"])
 @auth.login_required
 def download_db():
-       return send_from_directory(f"{app.root_path}/../data", "main.db")
+       return send_from_directory(f"{PATH}/data", "main.db")
index 65e4cb57f6ed1754dde5dae7343c39ecaf8abd3b..9a58ef7bab4d70076923b97df0376c3be51115b7 100644 (file)
@@ -12,8 +12,7 @@ from argo.database.read import read as database_read
 from argo import STAR
 
 def admin_main():
 from argo import STAR
 
 def admin_main():
-       from argo import app
-       assets = glob(os.path.join(app.root_path, "static", "media", "assets", "*"))
+       assets = glob(os.path.join(os.getenv("DELTA_PATH"), "argo", "static", "media", "assets", "*"))
        assets = [path.split("argo")[-1] for path in assets]
 
        return render_template(
        assets = [path.split("argo")[-1] for path in assets]
 
        return render_template(
index e408c87974f86593b58125ca5d9d028ef4723960..e7b5516f8ecacd4daeb31a9cd8f636177215b3f7 100644 (file)
@@ -4,11 +4,14 @@
        check if file exists and pragam check the database on init
 """
 
        check if file exists and pragam check the database on init
 """
 
-from .utils import integrity_check, optimize
 import sqlite3
 import os
 
 import sqlite3
 import os
 
-assert os.path.exists("./data/main.db"), "Database missing"
+PATH = f"{os.getenv('DELTA_PATH')}/data/main.db"
+
+from .utils import integrity_check, optimize
+
+assert os.path.exists(PATH), "Database missing"
 assert integrity_check(), "Database integrity error"
 
 optimize()
 assert integrity_check(), "Database integrity error"
 
 optimize()
index b180b39bfc166be79b9597973950a98fff50d07c..7452b4cc0958e06da823572c75223bdd6d9649ee 100644 (file)
@@ -1,12 +1,13 @@
 import sqlite3
 
 from .utils import list_all, list_views
 import sqlite3
 
 from .utils import list_all, list_views
+from . import PATH
 
 def read_all_current():
        tables = list_all()
        indexes = read_indexes()
 
 
 def read_all_current():
        tables = list_all()
        indexes = read_indexes()
 
-       with sqlite3.connect("./data/main.db") as connection:
+       with sqlite3.connect(PATH) as connection:
                cursor = connection.cursor()
 
                data = {}
                cursor = connection.cursor()
 
                data = {}
@@ -30,7 +31,7 @@ def read(table):
        """
                reads a table by name
        """
        """
                reads a table by name
        """
-       with sqlite3.connect("./data/main.db") as connection:
+       with sqlite3.connect(PATH) as connection:
                cursor = connection.cursor()
 
                cursor.execute(f"SELECT * FROM {table};")
                cursor = connection.cursor()
 
                cursor.execute(f"SELECT * FROM {table};")
@@ -58,7 +59,7 @@ def read_views(table=None):
        return data
 
 def read_indexes():
        return data
 
 def read_indexes():
-       with sqlite3.connect("./data/main.db") as connection:
+       with sqlite3.connect(PATH) as connection:
                cursor = connection.cursor()
 
                cursor.execute("SELECT * FROM indexes;")
                cursor = connection.cursor()
 
                cursor.execute("SELECT * FROM indexes;")
index 6866761e382cdbb63c1a284525a0f964a15d8c3e..b9e3c1b1640e2bbf0b8b15b13b7f6ef0ab96b83f 100644 (file)
@@ -1,10 +1,12 @@
 import sqlite3
 
 import sqlite3
 
+from . import PATH
+
 def integrity_check():
        """
                check the database is ok and return true if it is
        """
 def integrity_check():
        """
                check the database is ok and return true if it is
        """
-       with sqlite3.connect("./data/main.db") as connection:
+       with sqlite3.connect(PATH) as connection:
                cursor = connection.cursor()
                integrity = cursor.execute('PRAGMA integrity_check')
 
                cursor = connection.cursor()
                integrity = cursor.execute('PRAGMA integrity_check')
 
@@ -14,7 +16,7 @@ def optimize():
        """
                check the database is ok and return true if it is
        """
        """
                check the database is ok and return true if it is
        """
-       with sqlite3.connect("./data/main.db") as connection:
+       with sqlite3.connect(PATH) as connection:
                cursor = connection.cursor()
                integrity = cursor.execute('PRAGMA optimize')
 
                cursor = connection.cursor()
                integrity = cursor.execute('PRAGMA optimize')
 
@@ -22,7 +24,7 @@ def list_all():
        """
                get a list of all the tables and views in the database
        """
        """
                get a list of all the tables and views in the database
        """
-       with sqlite3.connect("./data/main.db") as connection:
+       with sqlite3.connect(PATH) as connection:
                cursor = connection.cursor()
                cursor.execute("SELECT name FROM sqlite_master WHERE type IN ('table', 'view');")
                return [table[0] for table in cursor.fetchall()]
                cursor = connection.cursor()
                cursor.execute("SELECT name FROM sqlite_master WHERE type IN ('table', 'view');")
                return [table[0] for table in cursor.fetchall()]
@@ -31,7 +33,7 @@ def list_views():
        """
                get a list of all the views in the database
        """
        """
                get a list of all the views in the database
        """
-       with sqlite3.connect("./data/main.db") as connection:
+       with sqlite3.connect(PATH) as connection:
                cursor = connection.cursor()
                cursor.execute("SELECT name FROM sqlite_master WHERE type='view';")
                return [table[0] for table in cursor.fetchall()]
                cursor = connection.cursor()
                cursor.execute("SELECT name FROM sqlite_master WHERE type='view';")
                return [table[0] for table in cursor.fetchall()]
index eea0126075c54c61fad9a861b16ce1f365b2517a..36bef903cf5378d35ff8b60bec0000c8f0982ed4 100644 (file)
@@ -3,9 +3,11 @@ import sqlite3
 from .utils import list_all
 from .read import read
 
 from .utils import list_all
 from .read import read
 
+from . import PATH
+
 def write(data):
 
 def write(data):
 
-       with sqlite3.connect("./data/main.db") as connection:
+       with sqlite3.connect(PATH) as connection:
                cursor = connection.cursor()
 
                for key in data:
                cursor = connection.cursor()
 
                for key in data: