From cd57eca7d36b0bf1c75d2e04061993ddf3a3eea4 Mon Sep 17 00:00:00 2001 From: Vivek Santayana Date: Sat, 20 Aug 2022 15:40:41 +0100 Subject: [PATCH] Restructure install script --- ref-test/install.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/ref-test/install.py b/ref-test/install.py index e198996..05d140f 100755 --- a/ref-test/install.py +++ b/ref-test/install.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from main import app from app.extensions import db +from app.models import * from app.tools.data import save from app.tools.logs import write from sqlalchemy_utils import create_database, database_exists @@ -21,14 +22,12 @@ with app.app_context(): if not path.isfile(f'./{data}/logs/users.log'): write('users.log', 'Log file created.') if not path.isfile(f'./{data}/logs/system.log'): write('system.log', 'Log file created.') if not path.isfile(f'./{data}/logs/tests.log'): write('tests.log', 'Log file created.') - if not database_exists(database_uri): - create_database(database_uri) - write('system.log', 'No database found. Creating a new database.') - from app.models import * - db.create_all() - write('system.log', 'Creating database schema.') if not path.isfile(f'./{data}/.encryption.key'): write('system.log', 'No encryption key found. Generating new encryption key.') with open(f'./{data}/.encryption.key', 'wb') as key_file: key = Fernet.generate_key() - key_file.write(key) \ No newline at end of file + key_file.write(key) + if not database_exists(database_uri): + create_database(database_uri) + write('system.log', 'No database found. Creating a new database.') + db.create_all() \ No newline at end of file