forked from NC3-LU/MOSP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanager.py
73 lines (53 loc) · 1.74 KB
/
manager.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import logging
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
import mosp.scripts
import mosp.models
from mosp.bootstrap import application, db
logger = logging.getLogger('manager')
Migrate(application, db)
manager = Manager(application)
manager.add_command('db', MigrateCommand)
@manager.command
def uml_graph():
"UML graph from the models."
with application.app_context():
mosp.models.uml_graph(db)
@manager.command
def db_empty():
"Will drop every datas stocked in db."
with application.app_context():
mosp.models.db_empty(db)
@manager.command
def db_create():
"Will create the database."
with application.app_context():
mosp.models.db_create(db, application.config['DB_CONFIG_DICT'],
application.config['DATABASE_NAME'])
@manager.command
def db_init():
"Will create the database from conf parameters."
with application.app_context():
mosp.models.db_init(db)
@manager.command
def import_licenses_from_spdx():
"Import licenses from spdx.org."
print("Importing licenses from spdx.org...")
with application.app_context():
mosp.scripts.import_licenses_from_spdx()
@manager.command
def create_user(login, password):
"Initializes a user"
print("Creation of the user {} ...".format(login))
with application.app_context():
mosp.scripts.create_user(login, password, False)
@manager.command
def create_admin(login, password):
"Initializes an admin user"
print("Creation of the admin user {} ...".format(login))
with application.app_context():
mosp.scripts.create_user(login, password, True)
if __name__ == '__main__':
manager.run()