<commit_before>"""
Deploy reps.mozilla.org using Chief in dev/stage/production.

Requires commander_ which is installed on the systems that need it.

.. _commander: https://github.com/oremj/commander
"""

import os
import sys
import urllib
import urllib2

sys.path.append(os.path.dirname(os.path.abspath(__file__)))

from commander.deploy import task, hostgroups
import commander_settings as settings


NEW_RELIC_URL = 'https://rpm.newrelic.com/deployments.xml'
NEW_RELIC_APP_ID = getattr(settings, 'NEW_RELIC_APP_ID', False)
NEW_RELIC_API_KEY = getattr(settings, 'NEW_RELIC_API_KEY', False)


@task
def update_code(ctx, tag):
    """Update the code to a specific git reference (tag/sha/etc)."""
    with ctx.lcd(settings.SRC_DIR):
        ctx.local('git fetch')
        ctx.local('git checkout -f %s' % tag)
        ctx.local('git submodule sync')
        ctx.local('git submodule update --init --recursive')


@task
def update_assets(ctx):
    with ctx.lcd(settings.SRC_DIR):
        # LANG=en_US.UTF-8 is sometimes necessary for the YUICompressor.
        ctx.local('LANG=en_US.UTF8 python ./manage.py collectstatic --noinput')
        ctx.local('LANG=en_US.UTF8 python ./manage.py compress_jingo')


@task
def update_db(ctx):
    """Update the database schema, if necessary.
<commit_msg>Keep server directories clean.<commit_after>"""
Deploy reps.mozilla.org using Chief in dev/stage/production.

Requires commander_ which is installed on the systems that need it.

.. _commander: https://github.com/oremj/commander
"""

import os
import sys
import urllib
import urllib2

sys.path.append(os.path.dirname(os.path.abspath(__file__)))

from commander.deploy import task, hostgroups
import commander_settings as settings


NEW_RELIC_URL = 'https://rpm.newrelic.com/deployments.xml'
NEW_RELIC_APP_ID = getattr(settings, 'NEW_RELIC_APP_ID', False)
NEW_RELIC_API_KEY = getattr(settings, 'NEW_RELIC_API_KEY', False)


@task
def update_code(ctx, tag):
    """Update the code to a specific git reference (tag/sha/etc)."""
    with ctx.lcd(settings.SRC_DIR):
        ctx.local('git fetch')
        ctx.local('git checkout -f %s' % tag)
        ctx.local('git submodule sync')
        ctx.local('git submodule update --init --recursive')
        ctx.local("find . -type f -name '.gitignore' -o -name '*.pyc' -delete")
        ctx.local('git clean -xdff "vendor-local/"')


@task
def update_assets(ctx):
    with ctx.lcd(settings.SRC_DIR):
        # LANG=en_US.UTF-8 is sometimes necessary for the YUICompressor.
        ctx.local('LANG=en_US.UTF8 python ./manage.py collectstatic --noinput')
        ctx.local('LANG=en_US.UTF8 python ./manage.py compress_jingo')


@task
def update_db(ctx):
    """Update the database schema, if necessary.

{'fraction_non_alphanumeric': 0.12408491947291361, 'fraction_numerical': 0.0029282576866764276, 'mean_word_length': 3.845744680851064, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '4366663', 'n_tokens_mistral': 925, 'n_tokens_neox': 897, 'n_words': 232}