From 4feda8e24f93b0dd5b2f50b533275921dfb5601f Mon Sep 17 00:00:00 2001 From: Miguel BarĂ£o Date: Mon, 29 Nov 2021 13:39:10 +0000 Subject: [PATCH] minor cleanup in main.py --- perguntations/main.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/perguntations/main.py b/perguntations/main.py index 444b6e2..d63a72e 100644 --- a/perguntations/main.py +++ b/perguntations/main.py @@ -1,18 +1,18 @@ #!/usr/bin/env python3 ''' -Main file that starts the application and the web server +Start application and web server ''' # python standard library import argparse import logging +import logging.config import os from os import environ, path import ssl import sys -# from typing import Any, Dict # this project from perguntations.app import App, AppException @@ -20,7 +20,6 @@ from perguntations.serve import run_webserver from perguntations.tools import load_yaml from perguntations import APP_NAME, APP_VERSION - # ---------------------------------------------------------------------------- def parse_cmdline_arguments(): ''' @@ -32,7 +31,6 @@ def parse_cmdline_arguments(): 'included with this software before running the server.') parser.add_argument('testfile', type=str, - # nargs='+', # TODO help='tests in YAML format') parser.add_argument('--allow-all', action='store_true', @@ -121,7 +119,9 @@ def main(): # --- Setup logging ------------------------------------------------------ logging.config.dictConfig(get_logger_config(args.debug)) - logging.info('====================== Start Logging ======================') + logger = logging.getLogger(__name__) + + logger.info('====================== Start Logging ======================') # --- start application -------------------------------------------------- config = { @@ -137,8 +137,8 @@ def main(): try: app = App(config) except AppException: - logging.critical('Failed to start application.') - sys.exit(-1) + logger.critical('Failed to start application.') + sys.exit(1) # --- get SSL certificates ----------------------------------------------- if 'XDG_DATA_HOME' in os.environ: @@ -151,8 +151,8 @@ def main(): ssl_opt.load_cert_chain(path.join(certs_dir, 'cert.pem'), path.join(certs_dir, 'privkey.pem')) except FileNotFoundError: - logging.critical('SSL certificates missing in %s', certs_dir) - sys.exit(-1) + logger.critical('SSL certificates missing in %s', certs_dir) + sys.exit(1) # --- run webserver ---------------------------------------------------- run_webserver(app=app, ssl_opt=ssl_opt, port=args.port, debug=args.debug) -- libgit2 0.21.2