-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
51 lines (38 loc) · 1.15 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
#!/usr/bin/env python
import os
import subprocess
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager, Shell
from server import create_app, db
from server.invoice.models import Invoice
from server.payment_history.models import PaymentHistory
from server.client.models import Client
from server.config import Config
app = create_app(Config)
manager = Manager(app)
migrate = Migrate(app, db)
def make_shell_context():
return dict(app=app,
db=db,
Client=Client,
Invoice=Invoice,
PaymentHistory=PaymentHistory)
manager.add_command('shell', Shell(make_context=make_shell_context))
manager.add_command('db', MigrateCommand)
@manager.command
def reset_db():
"""
Recreates a local database. You probably should not use this on
production.
"""
db.drop_all()
db.create_all()
db.session.commit()
@manager.command
def format():
"""Runs the yapf and isort formatters over the project."""
yapf = 'yapf -r -i *.py server/'
print('Running {}'.format(yapf))
subprocess.call(yapf, shell=True)
if __name__ == '__main__':
manager.run()