forked from dashng/netseen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage.py
49 lines (37 loc) · 1.04 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
#!/usr/bin/env python
from __future__ import print_function
import os
import sys
import unittest
from flask_script import Manager
from netseen import create_app
from netseen.database import DataBase
sys.path.insert(0, os.getcwd())
manager = Manager(create_app)
@manager.command
def createdb(drop_first=False):
"""Creates the database."""
try:
if drop_first:
DataBase().drop_all()
DataBase().create_all()
except Exception as e:
print(e)
@manager.command
def test():
"""Runs the unit tests without coverage."""
tests = unittest.TestLoader().discover('netseen.tests', pattern='test*.py')
result = unittest.TextTestRunner(verbosity=2).run(tests)
if result.wasSuccessful():
return 0
else:
return 1
# @manager.command
# def create_admin():
# """Creates the admin user."""
# username = 'admin'
# password = 'admin'
# db.session.add(User(username=username, password=password, admin=True))
# db.session.commit()
if __name__ == '__main__':
manager.run()