-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage.py
executable file
·51 lines (33 loc) · 1.03 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
#!/usr/bin/env python
import os
from flask_script import Manager, Shell
from app import create_app
from flask import url_for
app = create_app(os.getenv('FLASK_CONFIG') or 'default')
manager = Manager(app)
def make_shell():
return dict(app=app)
manager.add_command("shell", Shell(make_context=make_shell))
def run_test(discover_name):
import unittest
tests = unittest.TestLoader().discover(discover_name)
unittest.TextTestRunner(verbosity=2).run(tests)
@manager.command
def test():
run_test('tests')
@manager.command
def list_routes():
import urllib
output = []
for rule in app.url_map.iter_rules():
options = {}
for arg in rule.arguments:
options[arg] = "[{0}]".format(arg)
methods = ','.join(rule.methods)
url = url_for(rule.endpoint, **options)
line = urllib.unquote("{:50s} {:20s} {}".format(rule.endpoint, methods, url))
output.append(line)
for line in sorted(output):
print line
if __name__ == '__main__':
manager.run()