-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
41 lines (32 loc) · 1.33 KB
/
manage.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
37
38
39
40
41
# -*- coding: utf-8 -*-
"""Script module for the YoAPI Flask server.
Examples:
manage.py resetdb --config yoapi.config.Default --model_names User
manage.py yo --to USERNAME --link www.google.com
manage.py login --username USERNAME --password PASSWORD
"""
# Monkey patch using gevent. This has to be done first, _always_.
from gevent import monkey
monkey.patch_all()
import inspect
import yoapi.manage
from flask_script import Command
from functools import partial
from yoapi.factory import create_api_app
from yoapi.manage import Manager
if __name__ == "__main__":
# The manager option is passed to the factory function. This allows us to
# specify which config we use from the command line.
manager = Manager(partial(create_api_app, name='prod-api'))
manager.add_option("--config", dest="config",
default='yoapi.config.Default')
manager.add_option("--impersonate", dest="impersonate")
# Iterate over manage module to get all commands.
for name in dir(yoapi.manage):
attr = getattr(yoapi.manage, name)
# Check if strict subclass of flask_script.Command
if inspect.isclass(attr) and issubclass(attr, Command) and \
attr != Command:
# Add the command to the manager.
manager.add_command(name.lower(), attr)
manager.run()