This repository has been archived by the owner on Nov 30, 2022. It is now read-only.
forked from luciotorre/spacecraft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfabfile.py
96 lines (71 loc) · 2.7 KB
/
fabfile.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
import os
import sys
from fabric.api import local
def bootstrap():
check_system_deps()
virtualenv_create()
install_requirements()
def run_server(*args):
check_bootstrap()
local('./virtualenv/bin/twistd -n spacecraft %s' % ' '.join(args))
def run_client():
check_bootstrap()
local('PYTHONPATH=. ./virtualenv/bin/python spacecraft/manual_client.py')
def run_monitor():
check_bootstrap()
local('PYTHONPATH=. ./virtualenv/bin/python spacecraft/monitor.py')
def clean():
local("rm -rf virtualenv")
def test():
check_bootstrap()
local('./virtualenv/bin/trial spacecraft')
def coverage():
cov = lambda args: local("virtualenv/bin/coverage " + args,
capture=False)
local("rm -rf .coverage coverage/")
cov("run ./virtualenv/bin/trial spacecraft")
cov("combine")
cov("html -d htmlcov/ --include='spacecraft/*'")
def versus(bot1, bot2, *server_args):
"""Start a server and two clients, and a monitor to watch them"""
check_bootstrap()
local('screen -dmS server ./virtualenv/bin/twistd -n spacecraft %s --start true' % ' '.join(server_args))
local('PYTHONPATH=. ./virtualenv/bin/python %s &' % bot1)
local('PYTHONPATH=. ./virtualenv/bin/python %s &' % bot2)
local('PYTHONPATH=. ./virtualenv/bin/python spacecraft/monitor.py ')
local('screen -X -S server quit')
# -----------------------------------------------------------------
# Tasks from here down aren't intended to be used directly
def virtualenv_create():
local("rm -rf virtualenv")
local("%s /usr/bin/virtualenv virtualenv" % sys.executable, capture=False)
def check_system_deps():
missing_bindeps = []
missing_pydeps = []
bindeps = ['svn', 'gcc', 'g++', 'swig']
pydeps = ['pygame', 'virtualenv', 'setuptools']
for dep in bindeps:
result = local('which %s || true' % dep, capture=True)
if not result:
missing_bindeps.append(dep)
for dep in pydeps:
result = local('''%s -c "try:
import %s
except ImportError:
print ':('
"''' % (sys.executable, dep), capture=True)
if result:
missing_pydeps.append(dep)
if missing_bindeps:
print "\nPlease install the following binary deps on your system:"
print '\n'.join(' * %s' % x for x in missing_bindeps)
if missing_pydeps:
print "Please install the following Python deps on your system:"
print '\n'.join(' * %s' % x for x in missing_pydeps)
if missing_bindeps or missing_pydeps:
sys.exit(1)
def install_requirements():
local("virtualenv/bin/pip install -U -r requirements.txt", capture=False)
def check_bootstrap():
if not os.path.isdir('virtualenv'):
bootstrap()