From f4e0865f678cb9fa4ba35322312a1128708dbbf9 Mon Sep 17 00:00:00 2001 From: Nikolai R Kristiansen Date: Sat, 17 Mar 2018 12:32:02 +0100 Subject: [PATCH] Simplify fabfile --- fabfile.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/fabfile.py b/fabfile.py index ff3fdbc..5222ac5 100644 --- a/fabfile.py +++ b/fabfile.py @@ -1,24 +1,23 @@ -from contextlib import contextmanager as _contextmanager +from contextlib import contextmanager from fabric.api import run, sudo, env, cd, prefix -from fabric.context_managers import shell_env env.use_ssh_config = True env.hosts = ['dreamcast.neuf.no'] env.project_path = '/var/www/neuf.no/infoskjerm2' env.user = 'gitdeploy' -env.activate = 'source {}/.venv/bin/activate'.format(env.project_path) -@_contextmanager +@contextmanager def virtualenv(): - with cd(env.project_path), prefix(env.activate): + with cd(env.project_path), prefix('pipenv shell'): yield def deploy(): - with shell_env(PIPENV_VENV_IN_PROJECT='yup'), virtualenv(): - run('git pull') # Get source - run('pipenv install') # install deps in virtualenv + run('git pull') # Get source + run('pipenv install') # install deps in virtualenv + + with virtualenv(): run('umask 022; python manage.py collectstatic --noinput') # Collect static run('python manage.py migrate') # Run DB migrations