-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile.py
70 lines (53 loc) · 1.71 KB
/
fabfile.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
import os
import sys
from fabric.api import local
from fabric.api import task
from fabric.colors import green
from fabric.colors import red
from fabric.context_managers import settings
DEFAULT_ENV = 'development'
@task
def clean():
"""Remove all .pyc files."""
print green('Clean up .pyc files')
local("find . -name '*.py[co]' -exec rm -f '{}' ';'")
@task
def shell(env=DEFAULT_ENV):
"""Run the shell in the environment."""
os.environ['CONFIG_ENV'] = './config/%s.yaml' % env
local('python manage.py shell')
@task
def test(args='', env='test'):
"""Run tests."""
os.environ['CONFIG_ENV'] = './config/%s.yaml' % env
clean()
print green('Running all tests')
cmd = ('nosetests -d --verbosity 3 --with-id --nocapture %s' % args)
with settings(warn_only=True, quiet=True):
success = local(cmd).succeeded
lint()
if success:
print(green('Tests finished running with success.'))
else:
print(red('Test finished running with errors.'))
sys.exit(1)
@task
def lint():
"""Check for lints"""
print green('Checking for lints')
return local("flake8 `find . -name '*.py' -not -path '*env/*'` "
"--ignore=E711,E712 --max-line-length=100").succeeded
@task
def bootstrap(env=DEFAULT_ENV):
"""Bootstrap the environment."""
os.environ['CONFIG_ENV'] = './config/%s.yaml' % env
local('mkdir -p logs')
print green('\nInstalling requirements')
local('pip install -r requirements-test.txt')
local('pip install -r requirements-development.txt')
local('pip install -r requirements.txt')
local('python setup.py develop')
@task
def serve(env=DEFAULT_ENV):
"""Start the server."""
local('python app.py')