From b798bba2d0fe9fcfcdc8eaafa15f6c0541a6da30 Mon Sep 17 00:00:00 2001 From: Miguel BarĂ£o Date: Sun, 15 Jan 2023 15:57:08 +0000 Subject: [PATCH] refactor and simplify main.py --- aprendizations/main.py | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/aprendizations/main.py b/aprendizations/main.py index 14e9514..99a95db 100644 --- a/aprendizations/main.py +++ b/aprendizations/main.py @@ -15,7 +15,7 @@ import sys from typing import Any, Dict # this project -from .learnapp import LearnApp, DatabaseUnusableError, LearnException +from .learnapp import LearnApp, LearnException from .serve import run_webserver from .tools import load_yaml from . import APP_NAME, APP_VERSION @@ -175,8 +175,7 @@ def main(): '--------------------------------------------------------------', sep='\n') sys.exit(1) - else: - logging.info('SSL certificates loaded') + logging.info('SSL certificates loaded') # --- start application -------------------------------------------------- try: @@ -184,23 +183,10 @@ def main(): prefix=arg.prefix, dbase=arg.db, check=arg.check) - except DatabaseUnusableError: - logging.critical('Failed to start application.') - print('--------------------------------------------------------------', - 'Could not find a usable database. Use one of the follwing ', - 'commands to initialize: ', - ' ', - ' initdb-aprendizations --admin # add admin ', - ' initdb-aprendizations -a 86 "Max Smart" # add student ', - ' initdb-aprendizations students.csv # add many students', - '--------------------------------------------------------------', - sep='\n') - sys.exit(1) - except LearnException as exc: - logging.critical('Failed to start backend: %s', str(exc)) + except LearnException: + logging.critical('Failed to start application') sys.exit(1) - else: - logging.info('LearnApp started') + logging.info('LearnApp started') # --- run webserver forever ---------------------------------------------- run_webserver(app=learnapp, ssl=ssl_ctx, port=arg.port, debug=arg.debug) -- libgit2 0.21.2