<commit_before>import urllib.parse
import urllib.request
import json
from django.core.urlresolvers import reverse_lazy
from manager.models import Build

from packager.settings import SLACK_NOTIFICATION_URL, AUR_PACKAGER_BASE_URL


def post(build):
    assert SLACK_NOTIFICATION_URL
    assert AUR_PACKAGER_BASE_URL
    url = AUR_PACKAGER_BASE_URL + str(reverse_lazy('manager:build_detail',
                                                   kwargs={'package_name': build.package.name, 'build_number': 1}))
    text = str(build)
    text += '\n{}'.format(url)
    if build.status == Build.SUCCESS:
        emoji = ':+1:'
    else:
        emoji = ':ghost:'
    name = '{}: {} {}'.format(build.status, build.package.name, build.version)

    data = {'text': text, 'username': name, 'icon_emoji': emoji}
    request = urllib.request.Request(SLACK_NOTIFICATION_URL)
    request.add_header('Content-type', 'application/json')
    urllib.request.urlopen(request, json.dumps(data).encode())<commit_msg>Update slack text<commit_after>import urllib.parse
import urllib.request
import json
from django.core.urlresolvers import reverse_lazy
from manager.models import Build

from packager.settings import SLACK_NOTIFICATION_URL, AUR_PACKAGER_BASE_URL


def post(build):
    assert SLACK_NOTIFICATION_URL
    assert AUR_PACKAGER_BASE_URL
    detail_url = AUR_PACKAGER_BASE_URL + str(reverse_lazy('manager:build_detail',
                                                          kwargs={'package_name': build.package.name,
                                                                  'build_number': 1}))
    download_url = AUR_PACKAGER_BASE_URL + str(reverse_lazy('manager:package_download',
                                                            kwargs={'package_name': build.package.name,
                                                                    'build_number': 1}))
    text = '{} {} <{}|Detail> <{}|Download>\n{}'.format(build.package.name, build.status, detail_url, download_url,
                                                        build.sha256)
    if build.status == Build.SUCCESS:
        emoji = ':+1:'
    else:
        emoji = ':ghost:'
    name = '{}: {} {}'.format(build.status, build.package.name, build.version)

    data = {'text': text, 'username': name, 'icon_emoji': emoji}
    request = urllib.request.Request(SLACK_NOTIFICATION_URL)
    request.add_header('Content-type', 'application/json')
    urllib.request.urlopen(request, json.dumps(data).encode())
{'fraction_non_alphanumeric': 0.1157556270096463, 'fraction_numerical': 0.003215434083601286, 'mean_word_length': 2.490883590462833, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '719420', 'n_tokens_mistral': 725, 'n_tokens_neox': 718, 'n_words': 133}