forked from neurostuff/neurostore
-
Notifications
You must be signed in to change notification settings - Fork 1
/
manage.py
50 lines (34 loc) · 1.16 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
"""
Command line management tools.
"""
import os
from flask_script import Manager, Shell
from flask_migrate import Migrate, MigrateCommand
from flask_security.utils import encrypt_password
from neurostuff.core import app, db, user_datastore
from neurostuff import ingest
from neurostuff import models
app.config.from_object(os.environ['APP_SETTINGS'])
migrate = Migrate(app, db, directory=app.config['MIGRATIONS_DIR'])
manager = Manager(app)
def _make_context():
return dict(app=app, db=db, ms=models)
manager.add_command('db', MigrateCommand)
manager.add_command("shell", Shell(make_context=_make_context))
@manager.command
def add_user(email, password):
""" Add a user to the database.
email - A valid email address (primary login key)
password - Any string
"""
user_datastore.create_user(
email=email, password=encrypt_password(password))
db.session.commit()
@manager.command
def ingest_neurosynth(max_rows=1000):
ingest.ingest_neurosynth(max_rows=max_rows)
@manager.command
def ingest_neurovault(verbose=False, limit=20):
ingest.ingest_neurovault(verbose=verbose, limit=limit)
if __name__ == '__main__':
manager.run()