This repository was archived by the owner on Jun 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtasks.py
More file actions
77 lines (61 loc) · 1.45 KB
/
tasks.py
File metadata and controls
77 lines (61 loc) · 1.45 KB
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
import os
import sys
from invoke import task
python = sys.executable
sys.path.append('src')
#
# Call python manage.py in a more robust way
#
def manage(c, cmd, env=None, **kwargs):
kwargs = {k.replace('_', '-'): v for k, v in kwargs.items() if v is not False}
opts = ' '.join(f'--{k} {"" if v is True else v}' for k, v in kwargs.items())
cmd = f'{python} manage.py {cmd} {opts}'
env = {**os.environ, **(env or {})}
path = env.get("PYTHONPATH", ":".join(sys.path))
env.setdefault('PYTHONPATH', f'src:{path}')
c.run(cmd, env=env)
#
# Django tasks
#
@task
def run(c, no_toolbar=False):
"""
Run development server
"""
env = {}
if no_toolbar:
env['DISABLE_DJANGO_DEBUG_TOOLBAR'] = 'true'
else:
manage(c, 'runserver 0.0.0.0:8000', env=env)
#
# DB management
#
@task
def db(c, migrate_only=False):
"""
Perform migrations
"""
if not migrate_only:
manage(c, 'makemigrations')
manage(c, 'migrate')
@task
def migrate(c):
c.run('python manage.py migrate')
@task
def install(c):
"""
Install all development dependencies
"""
c.run('pip install -r requirements.txt')
@task
def travis(c):
"""
Runs command that Travis CI runs
"""
c.run('python playground.py')
@task
def create_admin(c):
"""
Runs command that Travis CI runs
"""
c.run('python manage.py createsuperuser2 --username test1 --password test1 --noinput --email "blank@email.com"')