예제 #1
0
def setup_log_files_owner():
    """
    Runs django manage.py check command and sets logs folder owner after
    """
    django_manage('check')
    sudo('chown -R {user}:{group} {logpath}'.format(
        user=ctx('system.user'),
        group=ctx('system.group'),
        logpath=ctx('logs.dirs.root')))
예제 #2
0
def dumpdata(app, dest=None):
    """
    Runs dumpdata on a given app and fetch the file locally
    """
    if dest is None:
        django_manage('dumpdata --indent=2 {}'.format(app))
    else:
        tmp_file = '/tmp/{}.tmp'.format(app)
        django_manage('dumpdata --indent=2 {} > {}'.format(app, tmp_file))
        with open(dest, 'wb') as fd:
            get(tmp_file, fd, use_sudo=True)
        sudo('rm -f {}'.format(tmp_file))
예제 #3
0
def migrate():
    """
    Perform django migration (only if the django version is >= 1.7)
    """
    with hide('running', 'stdout'):
        version = django_manage('--version')
    if version_supports_migrations(version):
        print(cyan("Django migrate on {}".format(env.stage)))
        try:
            django_manage('migrate --noinput')
        except FabricException as e:
            print(
                yellow(
                    'WARNING: faked migrations because of exception {}'.format(
                        e)))
            django_manage('migrate --noinput --fake')
    else:
        print(
            yellow("Django {} does not support migration, skipping.".format(
                version)))
예제 #4
0
def collectstatic():
    """
    Collect static medias
    """
    print(cyan("Django collectstatic on {}".format(env.stage)))
    django_manage(ctx('django.commands.collectstatic'))
예제 #5
0
def manage(cmd):
    """
    Runs django manage.py with a given command
    """
    print(cyan("Django manage {} on {}".format(cmd, env.stage)))
    django_manage(cmd)