-
Notifications
You must be signed in to change notification settings - Fork 6
/
manage.py
61 lines (45 loc) · 1.4 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
# coding=utf-8
"""
manage
~~~~~~
Like Django's manage.py, but simpler. Provides useful commands to manage the project
"""
import os, sys, subprocess
from everblog import db
def show_tables():
"""Show all of the tables in database"""
print db.engine.table_names()
def drop_tables():
"""Drop all tables in database"""
db.drop_tables()
print 'Tables dropped'
def create_tables():
"""Create tables according to models"""
db.create_tables()
print 'Tables created'
def recreate_tables():
"""Drop all tables then recreate them"""
drop_tables()
create_tables()
def load_data():
"""Load data into database from fixtures.py"""
from everblog import fixtures
db.load_data(fixtures)
print 'Data loaded'
def recreate_tables_then_load_data():
"""Recreate all tables and load the fixtures data"""
drop_tables()
create_tables()
load_data()
def run_app():
"""Run the web application"""
from everblog import app
if len(sys.argv) < 2:
subprocess.call([sys.executable, 'manage.py', 'run_app'])
else:
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port = port)
if __name__ == '__main__':
from toolkit_library.inspector import ModuleInspector
inspector = ModuleInspector(sys.modules[__name__])
inspector.invoke(*sys.argv[1:])