forked from DmitryBurnaev/starlette-web
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommand.py
26 lines (21 loc) · 807 Bytes
/
command.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
import os
import sys
from starlette_web.common.app import get_asgi_application
from starlette_web.common.conf.utils import parse_startapp_known_args
from starlette_web.common.management.base import fetch_command_by_name, CommandError
if __name__ == "__main__":
args = parse_startapp_known_args()
os.environ.setdefault(
"STARLETTE_SETTINGS_MODULE",
args.settings or "starlette_web.tests.settings"
)
if len(sys.argv) < 2:
raise CommandError(
'Missing command name. Correct syntax is: "python command.py command_name ..."'
)
command = fetch_command_by_name(sys.argv[1])
app = get_asgi_application(
use_pool=args.use_pool,
run_checks_on_startup=not args.skip_checks,
)
command(app).run_from_command_line(sys.argv)