-
Notifications
You must be signed in to change notification settings - Fork 5
/
manage.py
56 lines (47 loc) · 1.17 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
import unittest
from flask_script import Manager, Shell, Server
from app import app, db
from app.fake_populate import populate
manager = Manager(app)
def make_shell_context():
return dict(app=app)
@manager.command
def recreate_db():
"""
Create the SQL database.
"""
db.drop_all()
db.create_all()
db.session.commit()
print("recreated the database")
@manager.command
def fake_populate():
"""
Load dummy data into db
"""
recreate_db()
populate()
print("populated database with dummy data")
@manager.command
def test():
"""
run unit tests
:return: result, successful or not
"""
tests = unittest.TestLoader().discover('tests', pattern='test*.py')
result = unittest.TextTestRunner(verbosity=2).run(tests)
if result.wasSuccessful():
return 0
return 1
@manager.command
def read_once():
"""
a one-time read from the license server.
"""
from app.read_licenses import read
read()
print('Read completed.')
manager.add_command('runserver', Server(threaded=True))
manager.add_command('shell', Shell(make_context=make_shell_context))
if __name__ == '__main__':
manager.run()