django-fab-deploy / fab_deploy /

#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'])
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.