chaloBEST/fabfile.py

47 lines
1.3 KiB
Python
Raw Permalink Normal View History

2011-11-26 12:22:40 +00:00
#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 = 'chaloBEST'
def production():
env.hosts = ['%(project_name)s@camp.r-w-x.org'%env, ]
env.project_root = '/srv/(project_name)]s'%env
def bzr_push():
local('bzr push bzr+ssh://%(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://%(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()
2012-05-10 21:29:05 +00:00
# virtual_run('python %(project_name)s/manage.py syncdb;python %(project_name)s/manage.py migrate'%env)
2011-11-26 12:22:40 +00:00
run('touch %(project_root)s/wsgi/django.wsgi'%env)