forked from qualitio/qualitio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile.py
76 lines (56 loc) · 2.52 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
from __future__ import with_statement
import os
from fabric.api import *
from fabric.contrib.project import rsync_project
from fabric.colors import green
def setup_development():
"Create development envirotment"
with hide('running', 'stdout'):
print("Creating development evnirotment: ... ")
print(" 1. Installing python libraries: python-setuptools, python-dev")
local('sudo apt-get install -y python-setuptools python-dev', capture=False)
print(" 2. Installing pip")
local('sudo easy_install pip', capture=False)
print(" 3. Installing virtualenv")
local('sudo pip install virtualenv', capture=False)
try:
workon = os.environ["WORKON_HOME"]
del(os.environ['VIRTUAL_ENV'])
print(" 4. Creating virtualenv environment")
local('virtualenv %s/qualitio-dev' % workon)
print(" 5. Downloading required development packages, this may take a while")
local('pip -E %s/qualitio-dev install -r requirements.txt' % workon)
print("\nDevelopment evnirotment for qualitio project created!" +
"\nType " + green("workon qualitio-dev") + " to start workoing!")
except KeyError:
print(" 4. Creating virtualenv environment")
local('virtualenv .virtualenv')
print(" 5. Downloading required development packages")
local('pip -E .virtualenv install -r requirements.txt')
print("\nDevelopment evnirotment for qualitio project created in " +
green("%s/.virtualenv" % os.getcwd()) + " directory")
def push():
"Get new development code to device"
rsync_project(remote_dir="/home/services/www/",
local_dir="qualitio",
delete=True,
exclude=[".git*",
"*.pyc",
"*.pyo"])
run("chown :dev -R /home/services/www/qualitio")
run("chmod g+rw -R /home/services/www/qualitio/data")
def requirements():
"Install required packages for application"
virtualenv = "source /home/services/python-virtualenvs/qualitio/bin/activate && "
with cd('/home/services/www/qualitio/'):
put("requirements.txt",
"/home/services/www/qualitio")
run(virtualenv+" pip install -r requirements.txt")
def restart():
"Restart apache"
sudo("/etc/init.d/apache2 restart")
def deploy():
"Full deploy: push and start"
push()
requirements()
restart()