django-fab-deploy / fab_deploy /

The default branch has multiple heads

Full commit
#coding: utf-8
from __future__ import with_statement
from fabric.api import *

from fab_deploy import mysql
from fab_deploy import utils

__all__ = ['migrate', 'manage', 'syncdb', 'compress', 'collectstatic', 'test',

def command_is_available(command):
    with settings(hide('warnings', 'running', 'stdout', 'stderr'), warn_only=True):
        output = run('python help ' + command)
    if output.failed:
        with settings(hide('warnings', 'running', 'stdout', 'stderr'), warn_only=True):
            test_output = run('python')
        if test_output.failed:
            return True
    return output.succeeded

def manage(command):
    """ Runs django management command.

        fab manage:createsuperuser
    if not command_is_available(command):
        warn('Management command "%s" is not available' % command)
        run('python ' + command)

def migrate(params='', do_backup=True):
    """ Runs migrate management command. Database backup is performed
    before migrations if ``do_backup=False`` is not passed. """
    if do_backup:
        backup_dir = env.conf['ENV_DIR'] + '/var/backups/before-migrate'
        run('mkdir -p ' + backup_dir)
        with settings(warn_only=True):
    manage('migrate --noinput %s' % params)

def syncdb(params=''):
    """ Runs syncdb management command. """
    manage('syncdb --noinput %s' % params)

def compress(params=''):
    with settings(warn_only=True):
        manage('synccompress %s' % params)

def collectstatic(params=''):
    manage('collectstatic --noinput %s' % params)

def test(what=''):
    """ Runs '' script from project root.
    Example content::


        default_tests='accounts forum firms blog'
        if [ $# -eq 0 ]
            ./ test $default_tests --settings=test_settings
            ./ test $* --settings=test_settings
    with settings(warn_only=True):
        run('./ ' + what)

#def coverage():
#    pass
#    with cd(env.conf['SRC_DIR']):
#        run('source %s/bin/activate; ./bin/' % env.conf['ENV_DIR'])