openmumbai/fabfile.py

48 lines
1.5 KiB
Python
Raw Normal View History

2012-06-09 18:15:50 +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 = 'openmumbai'
def production():
env.hosts = ['%(project_name)s@topomancy.com'%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():
2012-06-13 17:58:04 +00:00
bzr_push()
2012-06-09 18:15:50 +00:00
bzr_update()
# 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)
2012-08-14 06:07:50 +00:00
virtual_run('python %(project_root)s/openmumbai/manage.py collectstatic --noinput'%env)