<commit_before>#!/usr/bin/env python
import sys
import os
import requests
import subprocess
import json

config_file = os.path.join(
    os.path.dirname(__file__),
    'config.json'
)
config = json.load(open(config_file))

token = config['IRCNOTIFIER_KEY']
message = '!log {user} {sudo_user}: Deployed {rev} {msg}'.format(
    user=os.environ['USER'],
    sudo_user=os.environ['SUDO_USER'],
    rev=subprocess.check_output(["git", "rev-list", "HEAD",
                                 "--max-count=1", "--format=oneline"]
                                ).decode('utf-8').strip(),
    msg=' '.join(sys.argv[1:])
)

print(message)

requests.post('http://ircnotifier-test-01/v1/send', data={
    'token': token,
    'channels': '#wikimedia-cloud',  # T166420
    'message': message
})
<commit_msg>Logging to irc no longer supported -- fall back to stdout<commit_after>#!/usr/bin/env python
import sys
import os
import subprocess
import json

config_file = os.path.join(
    os.path.dirname(__file__),
    'config.json'
)
config = json.load(open(config_file))

token = config['IRCNOTIFIER_KEY']
message = '!log {user} {sudo_user}: Deployed {rev} {msg}'.format(
    user=os.environ['USER'],
    sudo_user=os.environ['SUDO_USER'],
    rev=subprocess.check_output(["git", "rev-list", "HEAD",
                                 "--max-count=1", "--format=oneline"]
                                ).decode('utf-8').strip(),
    msg=' '.join(sys.argv[1:])
)

print(message)

{'fraction_non_alphanumeric': 0.17634996582365003, 'fraction_numerical': 0.010252904989747095, 'mean_word_length': 3.021978021978022, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5746881', 'n_tokens_mistral': 507, 'n_tokens_neox': 499, 'n_words': 92}