From 3f68d88666c832e0af50c5f4543ba3513c5fb0cb Mon Sep 17 00:00:00 2001 From: Andrew Date: Sat, 25 May 2019 19:35:44 +0400 Subject: =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0?= =?UTF-8?q?=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=B0=D1=80=D0=B3=D1=83=D0=BC=D0=B5=D0=BD=D1=82=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=B0=D0=BD=D0=B4=D0=BD=D0=BE=D0=B9=20=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- day7/bootstrapper.py | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 day7/bootstrapper.py (limited to 'day7/bootstrapper.py') diff --git a/day7/bootstrapper.py b/day7/bootstrapper.py new file mode 100644 index 0000000..60d5de8 --- /dev/null +++ b/day7/bootstrapper.py @@ -0,0 +1,55 @@ +import argparse +import shelve +from config import CONFIG_DB_PATH +from sys import argv + +parser = argparse.ArgumentParser() + +parser.add_argument( + '--chunk-size', type=int, default=1024, + help='Size of chunk that server uses when fetching data from connection' +) + +parser.add_argument( + '--bg-color', type=str, default='white', + help='Default background color of all webpages' +) + +parser.add_argument('--short-log', action='store_true') +parser.add_argument('--show-errors', action='store_true') + +parser.add_argument( + '--log', default='log.log', + help='File where log will be written' +) +parser.add_argument( + '--cookies-db', default='db/cookies.db', + help='Path to file where cookies will be stored' +) + +parser.add_argument( + '--host', default='0.0.0.0', + help='IP of interface where server will be started' +) +parser.add_argument( + '--port', type=int, default=8888, + help='Port on which server will be started' +) + + +args = parser.parse_known_args(argv[1:])[0] + +with (shelve.open(CONFIG_DB_PATH), shelve.open(args.cookies_db)) as (config, cookies): + config['chunk'] = args.chunk_size + config['short_log'] = args.short_log + config['log_path'] = args.log + config['show_errors'] = args.show_errors + config['cookies_db_path'] = args.cookies_db + config['host'] = args.host + config['port'] = args.port + + cookies['bg_color'] = args.bg_color + + +import http_handler +http_handler.main() -- cgit v1.2.3