def build_static(): require('venv_activate') with lcd_git_root(): with lcd('project'): with prefix('source %s' % env.venv_activate): with prefix('PYTHONPATH+=":.."'): local('python manage.py collectstatic --settings=settings_build --noinput') local('python manage.py compress --settings=settings_build')
def update_static(): """ Collect static media into the static/ directory and upload. """ require('static_path') execute(build_static) with lcd_git_root(): rsync_project(remote_dir=env.static_path, local_dir='static/', extra_opts="--rsync-path='sudo rsync'")
def get_vagrant_config(vagrant_path='vagrant'): """ Parses vagrant configuration and returns it as dict of ssh parameters and their values """ with lcd_git_root(): with lcd(vagrant_path): result = local('vagrant ssh-config', capture=True) conf = {} for line in iter(result.splitlines()): parts = line.split() conf[parts[0]] = ' '.join(parts[1:]) return conf
def push_source(): require('app_path', 'project_name') # TODO detect if no changes made since last archive and skip push unless # force param = True with lcd_git_root(): local("git archive --format=tar HEAD | gzip > %(project_name)s.tar.gz" % env) put('%(project_name)s.tar.gz' % env, '/tmp/%(project_name)s.tar.gz' % env) local('rm %(project_name)s.tar.gz' % env) sudo("rm -rf %(app_path)s/*" % env) sudo('mkdir -p %(app_path)s' % env) with cd(env.app_path): sudo("tar zxf /tmp/%(project_name)s.tar.gz" % env) sudo("rm /tmp/%(project_name)s.tar.gz" % env) sudo('mkdir -p project/whoosh') sudo('chown www-data:www-data project/whoosh') sudo('chmod ug+rw project/whoosh')