-
Notifications
You must be signed in to change notification settings - Fork 1
/
tasks.py
89 lines (65 loc) · 1.94 KB
/
tasks.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
from shutil import copy
import sys
from invoke import (
task,
run
)
# define projects directories
devmine_dir = 'devmine'
config_dir = devmine_dir + '/config'
test_dir = devmine_dir + '/test'
func_test_dir = test_dir + '/functional'
unit_test_dir = test_dir + '/unit'
@task
def set_settings(environment='production', nosetests=''):
if environment not in ['production', 'development', 'test']:
print('Error: ' + environment + ' is not a valid parameter',
file=sys.stderr)
exit(1)
src = config_dir + '/settings-' + environment + '.py.sample'
dst = config_dir + '/settings.py'
print('Copying ' + src + ' to ' + dst)
copy(src, dst)
print('Done')
@task('set_settings')
def test_func(environment='test', nosetests='nosetests'):
run_cmd(nosetests + ' -w ' + func_test_dir)
@task('set_settings')
def test_unit(environment='test', nosetests='nosetests'):
run_cmd(nosetests + ' -w ' + unit_test_dir)
@task('set_settings', 'test_func', 'test_unit')
def test(environment='test', nosetests='nosetests'):
pass
@task('set_settings')
def setup():
src = 'alembic.ini.sample'
dst = 'alembic.ini'
print('Copying ' + src + ' to ' + dst)
copy(src, dst)
print('Done')
@task
def pep8():
cmd = 'pep8 run.py tasks.py ' + devmine_dir
run_cmd(cmd)
@task
def pyflakes():
cmd = 'pyflakes run.py tasks.py ' + devmine_dir
run_cmd(cmd)
@task('pep8', 'pyflakes')
def check():
pass
@task
def clean():
run_cmd("find . -name '__pycache__' -exec rm -rf {} +")
run_cmd("find . -name '*.pyc' -exec rm -f {} +")
run_cmd("find . -name '*.pyo' -exec rm -f {} +")
run_cmd("find . -name '*~' -exec rm -f {} +")
run_cmd("find . -name '._*' -exec rm -f {} +")
@task('clean')
def clean_env():
run_cmd('rm -r ./env && mkdir env && touch env/.keep')
def run_cmd(cmd):
"Run a system command verbosely."
print('Running \'' + cmd + '\'...')
run(cmd)
print('Done')