Commit b798bba2d0fe9fcfcdc8eaafa15f6c0541a6da30
1 parent
f780fbf0
Exists in
dev
refactor and simplify main.py
Showing
1 changed file
with
5 additions
and
19 deletions
Show diff stats
aprendizations/main.py
| ... | ... | @@ -15,7 +15,7 @@ import sys |
| 15 | 15 | from typing import Any, Dict |
| 16 | 16 | |
| 17 | 17 | # this project |
| 18 | -from .learnapp import LearnApp, DatabaseUnusableError, LearnException | |
| 18 | +from .learnapp import LearnApp, LearnException | |
| 19 | 19 | from .serve import run_webserver |
| 20 | 20 | from .tools import load_yaml |
| 21 | 21 | from . import APP_NAME, APP_VERSION |
| ... | ... | @@ -175,8 +175,7 @@ def main(): |
| 175 | 175 | '--------------------------------------------------------------', |
| 176 | 176 | sep='\n') |
| 177 | 177 | sys.exit(1) |
| 178 | - else: | |
| 179 | - logging.info('SSL certificates loaded') | |
| 178 | + logging.info('SSL certificates loaded') | |
| 180 | 179 | |
| 181 | 180 | # --- start application -------------------------------------------------- |
| 182 | 181 | try: |
| ... | ... | @@ -184,23 +183,10 @@ def main(): |
| 184 | 183 | prefix=arg.prefix, |
| 185 | 184 | dbase=arg.db, |
| 186 | 185 | check=arg.check) |
| 187 | - except DatabaseUnusableError: | |
| 188 | - logging.critical('Failed to start application.') | |
| 189 | - print('--------------------------------------------------------------', | |
| 190 | - 'Could not find a usable database. Use one of the follwing ', | |
| 191 | - 'commands to initialize: ', | |
| 192 | - ' ', | |
| 193 | - ' initdb-aprendizations --admin # add admin ', | |
| 194 | - ' initdb-aprendizations -a 86 "Max Smart" # add student ', | |
| 195 | - ' initdb-aprendizations students.csv # add many students', | |
| 196 | - '--------------------------------------------------------------', | |
| 197 | - sep='\n') | |
| 198 | - sys.exit(1) | |
| 199 | - except LearnException as exc: | |
| 200 | - logging.critical('Failed to start backend: %s', str(exc)) | |
| 186 | + except LearnException: | |
| 187 | + logging.critical('Failed to start application') | |
| 201 | 188 | sys.exit(1) |
| 202 | - else: | |
| 203 | - logging.info('LearnApp started') | |
| 189 | + logging.info('LearnApp started') | |
| 204 | 190 | |
| 205 | 191 | # --- run webserver forever ---------------------------------------------- |
| 206 | 192 | run_webserver(app=learnapp, ssl=ssl_ctx, port=arg.port, debug=arg.debug) | ... | ... |