def git_init_submodules(git_path): """ Initialise and update git submodules """ check_on_path('git') puts(info="Initialising git submodules") with cd(git_path): run('git submodule update --init') puts(success="Submodules initialised")
def create_virtualenv(venv_path, user, permissions='0750'): "Creates a virtualenv" check_on_path('virtualenv') if not files.exists(os.path.join(venv_path, "bin/activate")): create_directories(venv_path, user, permissions) puts(info='Creating virtualenv at %s' % venv_path) run("virtualenv --no-site-packages %s" % venv_path) puts(success='virtualenv created') return 1 else: puts(info='virtualenv already exists at %s' % venv_path)
def restart_services(): """ Restarts/reloads gunicorn, nginx and memcached """ check_on_path('supervisorctl') # restart all processes controlled by supervisord sudo('supervisorctl restart all') # restart nginx sudo('/etc/init.d/nginx restart') # restart memcached sudo('/etc/init.d/memcached restart')
def git_pull(destination): """ Update the git repository at destination. """ check_on_path('git') puts(info="Updating git repository in %s" % destination) if run("test -d %s" % destination).succeeded: with cd(destination): run('git pull') puts(success="Repository updated") else: puts(error="Unable to pull - destination directory doesn't exist") abort("Aborting")
def git_clone(repo_path, destination, user): """ Clone the git repository at repo_path to destination. If destination doesn't exist, it will be created and owned by user. """ check_on_path('git') puts(info="Cloning git repository %s into %s" % (repo_path, destination)) with settings(warn_only=True): if run("test -d %s" % destination).failed: puts(info="Creating destination directory %s" % destination) create_directories(destination, user) puts(success="Destination directory created") run('git clone %s %s' % (repo_path, destination)) puts(success="Repository cloned")