<commit_before>from tempfile import mkdtemp
from shutil import rmtree
from fabric.operations import put
from fabric.api import task, run, sudo, local, abort
from fabric.context_managers import cd


repo = 'git://github.com/devilry/devilry-django.git'
branch = 'master'
checkout_dir = '/home/ubuntu/devilry-django'
prodenv_dir = checkout_dir + '/example-productionenv' # Must not end with ``/``
gunicorn_pidfile = '/tmp/gunicorn.pid'
backup_db_file = 'db.sqlite3.backup.sql'


def _install(*packages):
    sudo('apt-get install --yes {0}'.format(' '.join(packages)))

@task
def install_requirements():
    """
    Install requirements for the demo.
    """
    _install('python-virtualenv', 'fabric', 'nginx', 'git', 'postgresql',
             'libpq-dev', 'python-dev', 'build-essential', 'sqlite3')

@task
def checkout_devilry():
    """
    Checkout or pull.
    """
    from fabric.contrib.files import exists
    if not exists(checkout_dir):
        run('git clone {repo}'.format(repo=repo))
        with cd(checkout_dir):
            run('git checkout {branch}'.format(branch=branch))
    else:
        with cd(checkout_dir):
            run('git checkout {branch}'.format(branch=branch))
            run('git pull origin {branch}'.format(branch=branch))


@task
def refresh():
    """
    Refresh the virtualenv and rebuild static files.
    """
    with cd(prodenv_dir):
        run('fab refresh')

@task
def update_devilry():
    """
    Update devilry on aws.
    """
    stop_servers()
    with cd(prodenv_dir):
        run('fab update_devilry')
    start_servers()


@task
def setup():
    """
    Run install_requirements, checkout_devilry and refresh
    """
    install_requirements()
    checkout_devilry()
    refresh()


@task
def reset_demodb():
    with cd(prodenv_dir):
        run('fab reset_demodb')<commit_msg>awsdemo.fabfile: Added fast_update.<commit_after>from tempfile import mkdtemp
from shutil import rmtree
from fabric.operations import put
from fabric.api import task, run, sudo, local, abort
from fabric.context_managers import cd


repo = 'git://github.com/devilry/devilry-django.git'
branch = 'master'
checkout_dir = '/home/ubuntu/devilry-django'
prodenv_dir = checkout_dir + '/example-productionenv' # Must not end with ``/``
gunicorn_pidfile = '/tmp/gunicorn.pid'
backup_db_file = 'db.sqlite3.backup.sql'


def _install(*packages):
    sudo('apt-get install --yes {0}'.format(' '.join(packages)))

@task
def install_requirements():
    """
    Install requirements for the demo.
    """
    _install('python-virtualenv', 'fabric', 'nginx', 'git', 'postgresql',
             'libpq-dev', 'python-dev', 'build-essential', 'sqlite3')

@task
def checkout_devilry():
    """
    Checkout or pull.
    """
    from fabric.contrib.files import exists
    if not exists(checkout_dir):
        run('git clone {repo}'.format(repo=repo))
        with cd(checkout_dir):
            run('git checkout {branch}'.format(branch=branch))
    else:
        with cd(checkout_dir):
            run('git checkout {branch}'.format(branch=branch))
            run('git pull origin {branch}'.format(branch=branch))


@task
def refresh():
    """
    Refresh the virtualenv and rebuild static files.
    """
    with cd(prodenv_dir):
        run('fab refresh')


@task
def fast_update():
    """
    Run ``fab refreshstatic`` in prodenv.
    """
    stop_servers()
    with cd(prodenv_dir):
        run('git pull')
        run('fab refreshstatic')
    start_servers()

@task
def update_devilry():
    """
    Update devilry on aws.
    """
    stop_servers()
    with cd(prodenv_dir):
        run('fab update_devilry')
    start_servers()


@task
def setup():
    """
    Run install_requirements, checkout_devilry and refresh
    """
    install_requirements()
    checkout_devilry()
    refresh()


@task
def reset_demodb():
    with cd(prodenv_dir):
        run('fab reset_demodb')
{'fraction_non_alphanumeric': 0.1368421052631579, 'fraction_numerical': 0.0015404364569961489, 'mean_word_length': 3.2719298245614037, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5786987', 'n_tokens_mistral': 1287, 'n_tokens_neox': 1245, 'n_words': 299}