forked from RocketRace/robot-is-you
-
Notifications
You must be signed in to change notification settings - Fork 0
/
loader.py
37 lines (28 loc) · 858 Bytes
/
loader.py
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
import sys
from config import *
from src.db import Database
from src.web.load import load
async def main(args):
db = Database()
await db.connect(db_path)
await load(db, force_flags=args.force)
if __name__ == "__main__":
import asyncio
import argparse
import logging
args_parser = argparse.ArgumentParser()
args_parser.add_argument("--log-level", default="INFO")
args_parser.add_argument("--force", default=[], metavar="load_flag", nargs="+", type=str)
args = args_parser.parse_args()
logging.basicConfig(level=logging.WARNING)
logger = logging.getLogger(__name__)
try:
logger.setLevel(args.log_level)
logging.getLogger("src.web.load").setLevel(args.log_level)
except ValueError:
logger.fatal(f"Invalid log level {args.log_level}")
sys.exit(1)
try:
asyncio.run(main(args))
except KeyboardInterrupt:
logger.info("Exiting")