This repository was archived by the owner on Mar 21, 2024. It is now read-only.
forked from flozzone/aurora
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.py
134 lines (94 loc) · 3 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
from invoke import task
import os
import sys
#
# This is a [invoke](http://www.pyinvoke.org/) tasks file which is used to automate specific tasks needed
# for debugging and deployment.
#
@task
def install(ctx, fresh=False):
""" Install the virtual environment.
:param fresh: Remove the virtual environment before.
"""
venv(ctx, fresh)
@task
def prepare(ctx, fresh=False):
""" Install requirements and prepare database.
:param fresh: Remove the database before.
"""
deps(ctx)
db(ctx, fresh=fresh)
# populate database only on a fresh database
if fresh:
populate(ctx)
@task
def venv(ctx, fresh=False):
""" Create the virtual python environment
:param fresh: Remove the virtual environment before.
"""
import shutil
if os.path.exists('.venv'):
if fresh:
shutil.rmtree('.venv')
else:
print('virtualenv already created, run again with --fresh to reinstall it.')
return
ctx.run('virtualenv --python=python3 .venv')
@task
def deps(ctx):
""" Install project dependencies"""
ctx.run('pip install --upgrade pip wheel distribute')
ctx.run('pip install --upgrade -r requirements_dev.txt')
try:
import sherlock
except ImportError:
ctx.run('cd PlagCheck/hashing/sherlock && python setup.py install')
@task
def populate(ctx):
""" Run populate_demo_data """
ctx.run('python manage.py populate_demo_data', pty=True)
@task
def db(ctx, fresh=False, demo=False, plagcheck=False):
""" Wipe databases and recreate them.
:param plagcheck: Wipe also plagcheck database (default=False)
:param demo: Populate demo data (default=True)
:param migrate: Do also migrations (default=False)
"""
if fresh:
ctx.run('rm -f database.db')
ctx.run('python manage.py migrate')
if plagcheck:
ctx.run('rm -f database-plagcheck.db')
ctx.run('python manage.py migrate --database=plagcheck --noinput')
ctx.run('celery purge -f')
if demo:
populate(ctx)
@task
def server(ctx):
""" Run the debugging webserver"""
ctx.run('python manage.py runserver', pty=True)
@task
def celery(ctx, worker=1):
""" Run the background worker"""
ctx.run('python manage.py celery worker -E --loglevel=INFO --concurrency={0}'.format(worker), pty=True)
@task
def flower(ctx):
""" Run the monitor for the message queue"""
ctx.run('celery flower', pty=True)
@task
def static(ctx):
""" Install static files"""
ctx.run('python manage.py collectstatic --clear --noinput')
ctx.run('python manage.py collectstatic --noinput')
@task
def server(ctx):
""" Run the debugging webserver"""
ctx.run('python manage.py runserver', pty=True)
@task
def celery(ctx, worker=1):
""" Run the background worker"""
ctx.run('python manage.py celery worker -E --loglevel=INFO --concurrency={0}'.format(worker), pty=True)
@task
def flower(ctx):
""" Run the monitor for the message queue"""
ctx.run('celery flower', pty=True)