-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathquery.py
More file actions
46 lines (35 loc) · 1.22 KB
/
Copy pathquery.py
File metadata and controls
46 lines (35 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
def main() -> None:
from argparse import ArgumentParser
parser = ArgumentParser(
description='A script for querying analyzed questions',
add_help=False,
)
parser.add_argument(
'config_file',
nargs='?',
default='config.toml',
help='Path to the configuration file. Defaults to "config.toml".',
)
parser.add_argument(
'-h',
'--help',
action='help',
help='If specified, the script shows this help message and exits.',
)
args = parser.parse_args()
from logging import getLogger
from lib.configs import read_config
from lib.time import time_tracker
config = read_config(args.config_file).querier
logger = getLogger('script')
with time_tracker('The script is stopped. Time elapsed: {}', logger.info):
logger.info('Press Ctrl+C to stop this script')
from lib.querier import query
try:
query(config)
except KeyboardInterrupt:
logger.info('Ctrl+C received, stopping the script...')
except Exception:
logger.exception('An unknown error has occurred, the script will be stopped shortly')
if __name__ == '__main__':
main()