forked from quokkaproject/quokka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage.py
executable file
·74 lines (57 loc) · 1.62 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging
from flask.ext.script import Manager, Server
from flask.ext.collect import Collect
from quokka import create_app
from quokka.core.db import db
from quokka.ext.blueprints import load_blueprint_commands
app = create_app()
if app.config.get("LOGGER_ENABLED"):
logging.basicConfig(
level=getattr(logging, app.config.get("LOGGER_LEVEL", "DEBUG")),
format=app.config.get(
"LOGGER_FORMAT",
'%(asctime)s %(name)-12s %(levelname)-8s %(message)s'),
datefmt=app.config.get("LOGGER_DATE_FORMAT", '%d.%m %H:%M:%S')
)
manager = Manager(app)
manager.add_option("-c", "--config",
dest="config", required=False,
default='quokka.settings')
collect = Collect()
collect.init_script(manager)
@manager.shell
def make_shell_context():
" Update shell. "
return dict(app=app, db=db)
@manager.command
def check():
"""Prints app status"""
from pprint import pprint
print("Extensions.")
pprint(app.extensions)
print("Modules.")
pprint(app.blueprints)
print("App.")
return app
@manager.command
def populate():
"""Populate the database with sample data"""
from quokka.utils.populate import Populate
Populate(db)()
@manager.command
def show_config():
"print all config variables"
from pprint import pprint
print("Config.")
pprint(dict(app.config))
manager.add_command("run0", Server(
use_debugger=True,
use_reloader=True,
host='0.0.0.0',
port=8000
))
load_blueprint_commands(manager)
if __name__ == '__main__':
manager.run()