<commit_before>import os
import sys

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

from commander.deploy import hostgroups, task
from commander.settings import config

import commander_settings as settings


_src_dir = lambda *p: os.path.join(settings.SRC_DIR, *p)
VIRTUALENV = os.path.join(os.path.dirname(settings.SRC_DIR), 'venv')


def setup_notifier():
    notifier_endpoint = getattr(settings, 'NOTIFIER_ENDPOINT', None)
    notifier_key = getattr(settings, 'NOTIFIER_KEY', None)
    null_notify = lambda a: None
    if not notifier_endpoint:
        return null_notify

    try:
        import pushbotnotify
    except ImportError:
        return null_notify

    notifier = pushbotnotify.Notifier(endpoint=notifier_endpoint,
                                      api_key=notifier_key)
    config['notifiers'] = [notifier.notify]

    return notifier.notify


notify = setup_notifier()


@task
def create_virtualenv(ctx):
    venv = VIRTUALENV
    if not venv.startswith('/data'):
        raise Exception('venv must start with /data')  # this is just to avoid rm'ing /

    ctx.local('rm -rf %s' % venv)
    ctx.local('virtualenv --distribute --never-download %s' % venv)

    ctx.local('%s/bin/pip install --exists-action=w --no-deps --no-index '
              '--download-cache=/tmp/pip-cache -f %s '
              '-r %s/requirements/prod.txt' %
              (venv, settings.PYREPO, settings.SRC_DIR))<commit_msg>Notifier is too chatty.<commit_after>import os
import sys

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

from commander.deploy import hostgroups, task

import commander_settings as settings


_src_dir = lambda *p: os.path.join(settings.SRC_DIR, *p)
VIRTUALENV = os.path.join(os.path.dirname(settings.SRC_DIR), 'venv')


def setup_notifier():
    notifier_endpoint = getattr(settings, 'NOTIFIER_ENDPOINT', None)
    notifier_key = getattr(settings, 'NOTIFIER_KEY', None)
    null_notify = lambda a: None
    if not notifier_endpoint:
        return null_notify

    try:
        import pushbotnotify
    except ImportError:
        return null_notify

    notifier = pushbotnotify.Notifier(endpoint=notifier_endpoint,
                                      api_key=notifier_key)

    return notifier.notify


notify = setup_notifier()


@task
def create_virtualenv(ctx):
    venv = VIRTUALENV
    if not venv.startswith('/data'):
        raise Exception('venv must start with /data')  # this is just to avoid rm'ing /

    ctx.local('rm -rf %s' % venv)
    ctx.local('virtualenv --distribute --never-download %s' % venv)

    ctx.local('%s/bin/pip install --exists-action=w --no-deps --no-index '
              '--download-cache=/tmp/pip-cache -f %s '
              '-r %s/requirements/prod.txt' %
              (venv, settings.PYREPO, settings.SRC_DIR))
{'fraction_non_alphanumeric': 0.11475409836065574, 'fraction_numerical': 0.0, 'mean_word_length': 2.953521126760563, '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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1274681', 'n_tokens_mistral': 925, 'n_tokens_neox': 892, 'n_words': 202}