-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
31 lines (26 loc) · 921 Bytes
/
main.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
import os
import sys
import click
from flask_migrate import Migrate
from app import create_app, db, setup_app_manager
from app.models import Device, Variable, Event, EventType, Value, Experiment, Log
app = create_app(os.getenv('FLASK_CONFIG') or 'default')
migrate = Migrate(app, db)
setup_app_manager(app)
@app.cli.command()
@click.argument('test_names', nargs=-1)
def test(test_names):
"""Run the unit tests."""
import unittest
if test_names != ('', ):
tests = unittest.TestLoader().loadTestsFromNames(test_names)
else:
tests = unittest.TestLoader().discover('tests')
result = unittest.TextTestRunner(verbosity=2).run(tests)
sys.exit(len(result.failures))
@app.cli.command()
def profile():
"""Start the application under the code profiler."""
from werkzeug.contrib.profiler import ProfilerMiddleware
app.wsgi_app = ProfilerMiddleware(app.wsgi_app)
app.run()