forked from tomkralidis/HHypermap
-
Notifications
You must be signed in to change notification settings - Fork 1
/
pavement.py
59 lines (44 loc) · 1.49 KB
/
pavement.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
import os
from paver.easy import call_task, info, sh, task
@task
def reset_db():
"""
Reset the Django db, keeping the admin user
"""
sh("python manage.py sqlclear aggregator | python manage.py dbshell")
sh("python manage.py syncdb")
sh("python manage.py loaddata hypermap/aggregator/fixtures/aggregator.json")
@task
def run_tests():
"""
Executes the entire test suite.
"""
sh('python manage.py test hypermap.aggregator --settings=hypermap.settings.test --failfast')
sh('python manage.py test hypermap.dynasty --settings=hypermap.settings.test --failfast')
sh('flake8 hypermap')
@task
def run_integration_tests():
"""
Executes the entire test suite.
"""
call_task('start')
sh('python manage.py test tests.integration --settings=settings.test --failfast')
call_task('stop')
@task
def start():
sh('python manage.py runserver 0.0.0.0:8000 &')
@task
def stop():
kill_process('python', 'hypermap/manage.py')
def kill_process(procname, scriptname):
"""kill WSGI processes that may be running in development"""
# from http://stackoverflow.com/a/2940878
import signal
import subprocess
p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
out, err = p.communicate()
for line in out.decode().splitlines():
if procname in line and scriptname in line:
pid = int(line.split()[1])
info('Stopping %s %s %d' % (procname, scriptname, pid))
os.kill(pid, signal.SIGKILL)