This repository has been archived by the owner on Jan 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfabfile.py
82 lines (59 loc) · 1.51 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
"""
ATTENTION!!! This file has not been tested at all!
"""
import os
from contextlib import contextmanager as _contextmanager
from fabric import api
from fabric.api import env, lcd, local, run, runs_once
from fabric.context_managers import cd, prefix
api.env.hosts = ['lcrs@fair']
# NB! No trailing slashes
ENV_DIR = '/var/vhosts/lcrs/.virtualenvs/venv'
PROJECT_DIR = '/var/vhosts/lcrs/git'
def dirjoin(x):
return os.path.join(PROJECT_DIR, x)
# Use the local .ssh/config
env.use_ssh_config = True
env.virtualenv = ENV_DIR
env.activate = 'source %(virtualenv)s/bin/activate' % env
env.code_dir = PROJECT_DIR
@_contextmanager
def virtualenv():
with cd(env.virtualenv), prefix(env.activate), cd(env.code_dir):
yield
def git_pull():
"""
Pulls the latest master branch
"""
with cd(PROJECT_DIR):
run('git pull --ff origin master')
def syncdb():
"""
Syncs the database
"""
with virtualenv():
run('python manage.py syncdb')
def migrate():
"""
Migrates the project
"""
with virtualenv():
run('python manage.py migrate')
def collectstatic():
"""
Runs collectstatic on the remote project
"""
with virtualenv():
run('python manage.py collectstatic --noinput')
def install():
"""
Runs collectstatic on the remote project
"""
with virtualenv():
run('pip install -r requirements.txt')
def deploy():
git_pull()
install()
migrate()
collectstatic()
api.run('touch /var/vhosts/lcrs/reload')