-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile.py
118 lines (95 loc) · 2.85 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import sys
from fabric_helpers import sudo, cd, run
from fabric.api import settings
def local():
print "Running in local mode."
def remote():
print "Running in remote mode."
def info():
import project.settings as django_settings
if django_settings.DEBUG:
print "Server is in development mode."
else:
print "Server is in production mode."
def test():
with cd("project"):
run("python manage.py test")
def init_submodules():
run("git submodule init")
run("git submodule update")
def install_nodejs():
NODE_VERSION = "v0.6.5"
with settings(warn_only=True):
result = run("node --version")
if result.failed:
with cd("lib/node"):
run("git checkout %s" % NODE_VERSION)
sudo("apt-get install libssl-dev openssl")
run("./configure")
run("make")
sudo("make install")
else:
print "Node.js already installed"
install_npm()
def install_npm():
with settings(warn_only=True):
result = run("npm --version")
if result.failed:
sudo("apt-get install curl")
run("curl http://npmjs.org/install.sh | sh")
else:
print "npm already installed"
def install_coffee():
with settings(warn_only=True):
result = run("coffee --version")
if result.failed:
sudo("npm install -g coffee-script")
else:
print "Coffeescript already installed"
def install_tastypie():
try:
import tastypie
print "tastypie is installed - version %s." % str(tastypie.__version__)
except ImportError, e:
sudo("pip install mimeparse")
with cd('lib/django-tastypie'):
sudo("python setup.py install")
def install_jsonrpc():
try:
import jsonrpc
print "jsonrpc is installed."
except ImportError, e:
if e.message == "No module named jsonrpc":
with cd('lib/django-json-rpc'):
sudo("python setup.py install")
def install_django():
try:
import django
print "django is installed - version %s." % str(django.VERSION)
except ImportError, e:
if e.message == "No module named django":
with cd('lib/Django-1.3.1'):
sudo("python setup.py install")
def install():
init_submodules()
install_django()
install_jsonrpc()
install_tastypie()
install_nodejs()
#test()
def configure_mysql():
sudo("apt-get install mysql-server python-mysqldb")
with cd("project"):
run("rm -rf local*")
run("./django-create-local-settings")
run("./django-add-db")
run("./mysql-create-djangouser")
run("python manage.py syncdb")
def quickstart():
install()
configure_mysql()
info()
test()
def run_development():
with cd("project"):
run("python manage.py runserver 0.0.0.0:8000")