<commit_before>from fabric.context_managers import cd
from fabric.decorators import task, runs_once
from fabric.operations import prompt

from refabric.api import run, info
from refabric.context_managers import shell_env
from refabric.contrib import blueprints

from . import virtualenv
from .application.project import virtualenv_path, python_path, sudo_project

__all__ = ['manage', 'deploy', 'version', 'migrate', 'collectstatic']


blueprint = blueprints.get(__name__)


@task
def manage(cmd=''):
    """
    Run django management command
    """
    if not cmd:
        cmd = prompt('Enter django management command:')
    with sudo_project(), cd(python_path()), virtualenv.activate(virtualenv_path()), shell_env():
        return run('python manage.py {cmd}'.format(cmd=cmd))


@task
def deploy():
    """
    Migrate database and collect static files
    """
    # Migrate database
    migrate()

    # Collect static files
    collectstatic()


@task
def version():
    """
    Get installed version
    """
    if not hasattr(version, 'version'):
        v = manage('--version')
        version.version = tuple(map(int, v.split('\n')[0].strip().split('.')))
    return version.version


@task
@runs_once
def migrate():
    """
    Migrate database
    """
    info('Migrate database')
    if version() >= (1, 7):
        manage('migrate')
    elif blueprint.get('use_south', True):
        manage('migrate --merge')
        manage('syncdb --noinput')  # TODO: Remove?
    else:
        manage('syncdb --noinput')


@task
@runs_once
def collectstatic():
    """
    Collect static files
    """
    info('Collect static files')
    manage('collectstatic --noinput')<commit_msg>Add syncdb task to django blueprint<commit_after>from fabric.context_managers import cd
from fabric.decorators import task, runs_once
from fabric.operations import prompt

from refabric.api import run, info
from refabric.context_managers import shell_env, hide_prefix
from refabric.contrib import blueprints

from . import virtualenv
from .application.project import virtualenv_path, python_path, sudo_project

__all__ = ['manage', 'deploy', 'version', 'migrate', 'collectstatic', 'syncdb']


blueprint = blueprints.get(__name__)


@task
def manage(cmd=''):
    """
    Run django management command
    """
    if not cmd:
        cmd = prompt('Enter django management command:')
    with sudo_project(), cd(python_path()), virtualenv.activate(virtualenv_path()), shell_env(), hide_prefix():
        return run('python manage.py {cmd}'.format(cmd=cmd))


@task
def deploy():
    """
    Migrate database and collect static files
    """
    # Migrate database
    migrate()

    # Collect static files
    collectstatic()


@task
def version():
    """
    Get installed version
    """
    if not hasattr(version, 'version'):
        v = manage('--version')
        version.version = tuple(map(int, v.split('\n')[0].strip().split('.')))
    return version.version


@task
@runs_once
def migrate():
    """
    Migrate database
    """
    info('Migrate database')
    if version() >= (1, 7):
        manage('migrate')
    elif blueprint.get('use_south', True):
        manage('migrate --merge')
        manage('syncdb --noinput')  # TODO: Remove?
    else:
        manage('syncdb --noinput')


@task
@runs_once
def collectstatic():
    """
    Collect static files
    """
    info('Collect static files')
    manage('collectstatic --noinput')


@task
@runs_once
def syncdb():
    """
    Runs manage.py syncdb
    """
    info('Collect static files')
    manage('syncdb')
{'fraction_non_alphanumeric': 0.134588367518966, 'fraction_numerical': 0.0016858668165214948, 'mean_word_length': 3.3788437884378846, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2077281', 'n_tokens_mistral': 1074, 'n_tokens_neox': 1061, 'n_words': 292}