def worker_deploy(): env.user = '******' with virtualenv(django_settings.RQ_DEPLOY_PATH): for item in django_settings.RQ_PIP: run('pip install %s' % item) run('mkdir -p '+ django_settings.SVTGETSAVEFOLDER) for item in django_settings.RQ_SETTINGS_NEEDED: files.append('rq_settings.py', '%s=\'%s\'' % (item, get_config(item, 'FAIL!'))) for item in django_settings.RQ_IMPORTS: if os.path.isdir(os.path.join(django_settings.ROOT_DIR, item[0])): #If the source is a directory, create same directory on the target run('mkdir -p '+ item[1]) if item[1].find('/') != -1: #If the target filename contains a directory name, create that, and create a __init__.py run('mkdir -p '+ '/'.join(item[1].split('/')[:-1])) run('touch '+ '/'.join(item[1].split('/')[:-1]) + '/__init__.py') put(item[0], item[1])
def upload_tar_from_git(): "Create an archive from the current Git master branch and upload it" git_dir = local('git rev-parse --show-toplevel', capture=True) with lcd(git_dir): local('git archive --format=tar master | gzip > %s.tar.gz' % env.release) with virtualenv(django_settings.RQ_DEPLOY_PATH): put('%s.tar.gz' % env.release, 'release.tar.gz') run('tar zxf release.tar.gz') run('rm release.tar.gz') local('rm %s.tar.gz' % env.release)
def web_deploy(): upload_tar_from_git() with virtualenv(django_settings.RQ_DEPLOY_PATH): run('ls') run('pip install -r VHS/requirements.txt') run('python VHS/manage.py syncdb') run('python VHS/manage.py migrate') run('python VHS/manage.py collectstatic --noinput') # with cd(django_settings.RQ_DEPLOY_PATH): run('source bin/activate') # run('ls') # with cd(django_settings.RQ_DEPLOY_PATH): # with cd('VHS'): # run('ls') # run('python manage.py migrate') run('sudo supervisorctl restart vhs')