-
Notifications
You must be signed in to change notification settings - Fork 70
/
fabfile.py
46 lines (34 loc) · 1.07 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
import os
from contextlib import contextmanager
from fabric.api import env, run, prefix
def live():
"""Connects to the server."""
env.hosts = ['py3readiness.org']
env.user = os.environ.get('py3_user', '')
env.cwd = '/var/www/py3readiness.org'
env.connect_to = '{0}@{1}:{2}'.format(env.user, env.hosts[0], env.cwd)
def gitpull(tag=None):
"""Pulls upstream brunch on the server."""
if tag is not None:
run('git pull')
run('git checkout %s' % tag)
else:
run('git pull')
@contextmanager
def source_env():
"""Actives embedded virtual env"""
with prefix('source env/bin/activate'):
yield
def install_requirements():
"""Installs requirements inside vertualenv"""
with source_env():
run('pip install --force-reinstall -Ur requirements.txt')
def generate():
"""Generates updates using generate.py script"""
with source_env():
run('python generate.py')
def update(tag=None):
"""Updates changes in server (might restart webserver)"""
gitpull()
install_requirements()
generate()