-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage.py
executable file
·65 lines (48 loc) · 1.76 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
'''Management commands.'''
import os
from flask.ext.script import Manager
from managrr import app, db, models
from flask.ext.migrate import Migrate, MigrateCommand
manager = Manager(app)
app.config.from_object('config.BaseConfiguration')
migrate = Migrate(app, db)
manager = Manager(app)
manager.add_command('db', MigrateCommand)
@manager.command
def install():
'''Installs all required packages.'''
os.system('pip install -U -r requirements.txt')
@manager.command
def createdb():
'''Runs the db init, db migrate, db upgrade commands automatically'''
os.system('python manage.py db init')
os.system('python manage.py db migrate')
os.system('python manage.py db upgrade')
# Default creds, admin:managrr
user = models.Users('admin', '$2a$12$Z5tbHyVU4MeBBKbtgGQa3u9FniItNFPhHpK73rKwAVuAWkXN1oYpe', 'admin@example.com')
db.session.add(user)
db.session.commit()
@manager.shell
def make_shell_context():
return dict(app=app, db=db, models=models)
@manager.command
def test():
'''Runs the tests.'''
command = 'nosetests --verbosity=2 --nocapture'
os.system(command)
@manager.command
def lint():
'''Lints the codebase'''
command = 'flake8 --ignore E127,E221,F401 --max-line-length=220 --exclude=db_repository,tests,env,migrations .'
os.system(command)
@manager.command
def clean():
'''Cleans the codebase'''
commands = ["find . -name '*.pyc' -exec rm -f {} \;", "find . -name '*.pyo' -exec rm -f {} \;",
"find . -name '*~' -exec rm -f {} \;", "find . -name '__pycache__' -exec rmdir {} \;",
"rm -f app.db", "rm -rf migrations", "rm -f managrr.log"]
for command in commands:
print "Running " + command
os.system(command)
if __name__ == "__main__":
manager.run()