Commit 4feda8e24f93b0dd5b2f50b533275921dfb5601f
1 parent
50b1814f
Exists in
master
and in
1 other branch
minor cleanup in main.py
Showing
1 changed file
with
9 additions
and
9 deletions
Show diff stats
perguntations/main.py
1 | 1 | #!/usr/bin/env python3 |
2 | 2 | |
3 | 3 | ''' |
4 | -Main file that starts the application and the web server | |
4 | +Start application and web server | |
5 | 5 | ''' |
6 | 6 | |
7 | 7 | |
8 | 8 | # python standard library |
9 | 9 | import argparse |
10 | 10 | import logging |
11 | +import logging.config | |
11 | 12 | import os |
12 | 13 | from os import environ, path |
13 | 14 | import ssl |
14 | 15 | import sys |
15 | -# from typing import Any, Dict | |
16 | 16 | |
17 | 17 | # this project |
18 | 18 | from perguntations.app import App, AppException |
... | ... | @@ -20,7 +20,6 @@ from perguntations.serve import run_webserver |
20 | 20 | from perguntations.tools import load_yaml |
21 | 21 | from perguntations import APP_NAME, APP_VERSION |
22 | 22 | |
23 | - | |
24 | 23 | # ---------------------------------------------------------------------------- |
25 | 24 | def parse_cmdline_arguments(): |
26 | 25 | ''' |
... | ... | @@ -32,7 +31,6 @@ def parse_cmdline_arguments(): |
32 | 31 | 'included with this software before running the server.') |
33 | 32 | parser.add_argument('testfile', |
34 | 33 | type=str, |
35 | - # nargs='+', # TODO | |
36 | 34 | help='tests in YAML format') |
37 | 35 | parser.add_argument('--allow-all', |
38 | 36 | action='store_true', |
... | ... | @@ -121,7 +119,9 @@ def main(): |
121 | 119 | |
122 | 120 | # --- Setup logging ------------------------------------------------------ |
123 | 121 | logging.config.dictConfig(get_logger_config(args.debug)) |
124 | - logging.info('====================== Start Logging ======================') | |
122 | + logger = logging.getLogger(__name__) | |
123 | + | |
124 | + logger.info('====================== Start Logging ======================') | |
125 | 125 | |
126 | 126 | # --- start application -------------------------------------------------- |
127 | 127 | config = { |
... | ... | @@ -137,8 +137,8 @@ def main(): |
137 | 137 | try: |
138 | 138 | app = App(config) |
139 | 139 | except AppException: |
140 | - logging.critical('Failed to start application.') | |
141 | - sys.exit(-1) | |
140 | + logger.critical('Failed to start application.') | |
141 | + sys.exit(1) | |
142 | 142 | |
143 | 143 | # --- get SSL certificates ----------------------------------------------- |
144 | 144 | if 'XDG_DATA_HOME' in os.environ: |
... | ... | @@ -151,8 +151,8 @@ def main(): |
151 | 151 | ssl_opt.load_cert_chain(path.join(certs_dir, 'cert.pem'), |
152 | 152 | path.join(certs_dir, 'privkey.pem')) |
153 | 153 | except FileNotFoundError: |
154 | - logging.critical('SSL certificates missing in %s', certs_dir) | |
155 | - sys.exit(-1) | |
154 | + logger.critical('SSL certificates missing in %s', certs_dir) | |
155 | + sys.exit(1) | |
156 | 156 | |
157 | 157 | # --- run webserver ---------------------------------------------------- |
158 | 158 | run_webserver(app=app, ssl_opt=ssl_opt, port=args.port, debug=args.debug) | ... | ... |