<commit_before>import os
import sys
import requests
import click


HIPCHAT_API_URL = "http://api.hipchat.com"
NOTIFICATION_POST = "/v2/room/{}/notification"
AUTH_HEADER = "Authorization: Bearer {}"


@click.command()
@click.option('--auth_token_env_var', '-a',
              help="Environment variable containing authentication token to use for HipChat REST API.",
              )
@click.option('--channel', '-c',
              default="release pipeline",
              help="Channel to which the script should post a message.",
              )
@click.option('--message', '-m',
              default="Default message.",
              help="Message to send to HipChat channel.",
              )
def cli(auth_token_env_var, channel, message):
    """
    Post a message to a HipChat channel.
    """
    headers = {
        "Authorization": "Bearer {}".format(os.environ[auth_token_env_var])
    }
    msg_payload = {
        "color": "green",
        "message": message,
        "notify": False,
        "message_format": "text"
    }
    post_url = HIPCHAT_API_URL + NOTIFICATION_POST.format(channel)
    r = requests.post(post_url, headers=headers, json=msg_payload)

    # An exit code of 0 means success and non-zero means failure.
    success = r.status_code in (200, 201, 204)
    sys.exit(not success)


if __name__ == '__main__':
    cli()<commit_msg>Change script to reflect new pattern. Add more output.<commit_after>import sys
import requests
import click
import urllib


HIPCHAT_API_URL = "http://api.hipchat.com"
NOTIFICATION_POST = "/v2/room/{}/notification"
AUTH_HEADER_FIELD = "Authorization"
AUTH_HEADER_VALUE = "Bearer {}"


@click.command()
@click.option('--auth_token', '-a',
              envvar='HIPCHAT_AUTH_TOKEN',
              help="Authentication token to use for HipChat REST API.",
              )
@click.option('--channel', '-c',
              envvar='HIPCHAT_CHANNEL',
              help="Channel to which the script should post a message.",
              )
@click.option('--message', '-m',
              help="Message to send to HipChat channel.",
              required=True
              )
def cli(auth_token, channel, message):
    """
    Post a message to a HipChat channel.
    """
    if not channel:
        print "No HIPCHAT_CHANNEL defined - ignoring message send: {}".format(message)
        sys.exit(0)

    if not auth_token:
        print "No HIPCHAT_AUTH_TOKEN defined - ignoring message send: {}".format(message)
        sys.exit(0)

    headers = {
        AUTH_HEADER_FIELD: AUTH_HEADER_VALUE.format(auth_token)
    }
    msg_payload = {
        "color": "green",
        "message": message,
        "notify": False,
        "message_format": "text"
    }
    post_url = HIPCHAT_API_URL + NOTIFICATION_POST.format(urllib.quote(channel.strip()))
    r = requests.post(post_url, headers=headers, json=msg_payload)

    # An exit code of 0 means success and non-zero means failure.
    success = r.status_code in (200, 201, 204)
    if not success:
        print "Message send failed: {}".format(r.text)
    sys.exit(not success)


if __name__ == '__main__':
    cli()
{'fraction_non_alphanumeric': 0.12427745664739884, 'fraction_numerical': 0.007707129094412331, 'mean_word_length': 2.622093023255814, 'pattern_counts': {'":': 9, '<': 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': '6123258', 'n_tokens_mistral': 966, 'n_tokens_neox': 931, 'n_words': 247}