-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtasks.py
103 lines (75 loc) · 2.29 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
from invoke import task, Collection, Responder
import webbrowser
# USAGE: invoke [function_name]
@task
def start(c):
c.run('npm run dev & python manage.py runserver 0.0.0.0:8000')
@task
def init(c, colored=True):
c.run('python manage.py migrate')
c.run('python ./manage.py loaddata --ignorenonexistent db.json')
webbrowser.open('http://localhost:8000', new=0)
c.run('npm run dev & python manage.py runserver 0.0.0.0:8000')
@task
def dumpdata(c):
c.run('python ./manage.py dumpdata > db.json --natural-foreign --natural-primary -e contenttypes -e auth.Permission --indent 4')
@task
def loaddata(c):
c.run('python ./manage.py loaddata --ignorenonexistent db.json ')
@task
def createsetting(c):
c.run('cp dspexplorer/c.run_settings.py-example dspexplorer/c.run_settings.py')
@task
def freeze(c):
c.run('pip freeze > requirements.txt')
@task
def makemigrations(c):
c.run('python manage.py makemigrations')
@task
def migrate(c):
c.run('python manage.py migrate')
@task
def install(c):
c.run('pip install -r requirements.txt')
c.run('npm install')
@task
def installstatic(c):
c.run('python ./manage.py collectstatic')
@task
def test(c, filename=''):
c.run('python manage.py test %s -k' % filename)
@task
def test_e2e(c):
c.run('protractor protractor-conf.js')
@task
def runscript(c, name):
'''
USAGE: inv runscript -n [scriptname],
[scriptname] is a python script located in scripts/ directory or dspexplorer/ directory
:param c:
:param name:
:return:
'''
c.run('python ./manage.py runscript '+name)
@task
def staging(c):
responder = Responder(
pattern=r"Type 'yes' to continue, or 'no' to cancel",
response="yes\n",
)
c.run('python manage.py migrate')
c.run('npm i --allow-root --unsafe-perm')
c.run('npm run staging')
c.run('python ./manage.py collectstatic', watchers=[responder])
c.run('service apache2 restart')
@task
def production(c):
responder = Responder(
pattern=r"Type 'yes' to continue, or 'no' to cancel",
response="yes\n",
)
c.run('python manage.py migrate')
c.run('npm i --allow-root --unsafe-perm')
c.run('npm run prod')
c.run('python ./manage.py collectstatic', watchers=[responder])
c.run('service apache2 restart')