-
Notifications
You must be signed in to change notification settings - Fork 2
/
fabfile.py
47 lines (38 loc) · 1.47 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
#this is a fabfile, use it with fab from http://fabfile.org/
#
# initial setup:
# fab production setup
#
# deploy changes:
# fab production deploy
#
from os.path import join
from fabric.api import run, local, sudo, put, env
env.project_name = 'maskara'
def production():
env.hosts = ['%(project_name)[email protected]'%env, ]
env.project_root = '/srv/%(project_name)s'%env
def bzr_push():
local('bzr push bzr+ssh://%(project_name)s@%(host)s%(project_root)s'%env)
def bzr_update():
run('cd %(project_root)s;bzr update'%env)
def virtual_run(cmd, *a, **kw):
cmd = 'cd %s; source bin/activate; %s' % (env.project_root, cmd)
run(cmd, *a, **kw)
def update_requirements():
run('pip -E %(project_root)s install -r %(project_root)s/requirements.txt'%env)
def setup():
"""
Setup a fresh virtualenv
"""
local('bzr push --use-existing-dir bzr+ssh://%(project_name)s@%(host)s%(project_root)s'%env)
run('cd %(project_root)s; test -e .bzr/checkout || bzr checkout'%env)
run('virtualenv %(project_root)s'%env)
put(join('settings', '%(host)s.py'%env), join(env.project_root, env.project_name, 'local_settings.py'))
update_requirements()
def deploy():
bzr_push()
bzr_update()
virtual_run('python %(project_root)s/manage.py collectstatic --noinput'%env)
# virtual_run('python %(project_root)s/%(project_name)s/manage.py syncdb;python %(project_root)s/%(project_name)s/manage.py migrate'%env)
run('touch %(project_root)s/wsgi/django.wsgi'%env)