-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage.py
executable file
·52 lines (41 loc) · 1.21 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
#!flask/bin/python
import sys
try:
from app import app, db
from flask.ext.script import Manager, prompt_bool
from config import SQLALCHEMY_DATABASE_URI
from config import SQLALCHEMY_MIGRATE_REPO
from shutil import copyfile
import os.path
import datetime, time
except ImportError:
print 'It looks like you don\'t have project dependencies. Install them by executing app/install.sh.'
sys.exit(1)
manager = Manager(app)
@manager.command
def runserver():
app.run(host='0.0.0.0')
@manager.command
def runserver_debug():
app.run(host='0.0.0.0', debug=True)
@manager.command
def db_create():
if os.path.exists(SQLALCHEMY_DATABASE_URI[10:]):
print 'Database file already exists'
return
db.create_all()
@manager.command
def db_backup():
timestamp = datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S')
copyfile('app.db', SQLALCHEMY_MIGRATE_REPO + '/versions/' + timestamp + '.db')
@manager.command
def db_drop():
if prompt_bool("This operation will drop the database, continue?"):
db.drop_all()
@manager.command
def db_fill():
if prompt_bool("Proceeding to fill the database with data. Continue?"):
from app import fill_db
fill_db.fill_her_up()
if __name__ == '__main__':
manager.run()