from fabric.api import cd, sudo, env
import os

expected_vars = [
    'PROJECT',
]

for var in expected_vars:
    if var not in os.environ:
        raise Exception('Please specify %s environment variable' % (
            var,))

PROJECT = os.environ['PROJECT']
USER = os.environ.get('USER', 'jmbo')

env.path = os.path.join('/', 'var', 'praekelt', PROJECT)


def restart():
    sudo('/etc/init.d/nginx restart')
    sudo('supervisorctl reload')


def deploy():
    with cd(env.path):
        sudo('git pull', user=USER)
        sudo('ve/bin/python manage.py syncdb --migrate --noinput',
             user=USER)
        sudo('ve/bin/python manage.py collectstatic --noinput',
             user=USER)


def install_packages(force=False):
    with cd(env.path):
        sudo('ve/bin/pip install %s -r requirements.pip' % (
             '--upgrade' if force else '',), user=USER)

from fabric.api import cd, sudo, env
import os

PROJECT = os.environ.get('PROJECT', 'go-rts-zambia')
DEPLOY_USER = os.environ.get('DEPLOY_USER', 'jmbo')

env.path = os.path.join('/', 'var', 'praekelt', PROJECT)


def restart():
    sudo('/etc/init.d/nginx restart')
    sudo('supervisorctl reload')


def deploy():
    with cd(env.path):
        sudo('git pull', user=DEPLOY_USER)
        sudo('ve/bin/python manage.py syncdb --migrate --noinput',
             user=DEPLOY_USER)
        sudo('ve/bin/python manage.py collectstatic --noinput',
             user=DEPLOY_USER)


def install_packages(force=False):
    with cd(env.path):
        sudo('ve/bin/pip install %s -r requirements.pip' % (
             '--upgrade' if force else '',), user=DEPLOY_USER)

Fix USER in fabric file (the deploy user and ssh user aren't necessarily the same). Set default value for PROJECT (this is the go-rts-zambia repo after all).