<commit_before>"""
Copyright (C) 2016 by Strong Leaf Consultant Ltd.

GNU AGPL v3+

Bob-Bench xUnit file detection
"""

from benchupload import xunit
from benchupload import cidetect
import os
import sys
import requests


xunit_dest_url = "https://api.bob-bench.org/v1/xunit_upload.pl"

def post(url, ci, fnames):
    files = list(map(lambda x: (os.path.basename(x), open(x, 'rb')), fnames))
    data = {
        'x-is-github':  ci.is_github,
        'x-commit':     ci.commit,
        'x-tag':        ci.tag,
        'x-branch':     ci.branch,
        'x-buildnr':    ci.build_nr,
        'x-os-name':    ci.os_name,
        'x-repo-url':   ci.repo_url
    }
    res = requests.post(xunit_dest_url, data=data, files=files)
    if res.status_code != 200:
        sys.stderr.write("Failed to POST resources")
        sys.exit(43)

def main():
    ci = cidetect.detect()
    if not ci:
        sys.stderr.write("No CI system reported. Please report it to <EMAIL>\n")
        sys.exit(42)

    files = xunit.detect_xunit_files(os.curdir)
    if len(files) == 0:
        sys.stdout.write("No XML test results detected\n")
        sys.exit(0)

    post(xunit_dest_url, ci, files)

if __name__ == "__main__":
    main()
<commit_msg>Add trailing \n on the error log<commit_after>"""
Copyright (C) 2016 by Strong Leaf Consultant Ltd.

GNU AGPL v3+

Bob-Bench xUnit file detection
"""

from benchupload import xunit
from benchupload import cidetect
import os
import sys
import requests


xunit_dest_url = "https://api.bob-bench.org/v1/xunit_upload.pl"

def post(url, ci, fnames):
    files = list(map(lambda x: (os.path.basename(x), open(x, 'rb')), fnames))
    data = {
        'x-is-github':  ci.is_github,
        'x-commit':     ci.commit,
        'x-tag':        ci.tag,
        'x-branch':     ci.branch,
        'x-buildnr':    ci.build_nr,
        'x-os-name':    ci.os_name,
        'x-repo-url':   ci.repo_url
    }
    res = requests.post(xunit_dest_url, data=data, files=files)
    if res.status_code != 200:
        sys.stderr.write("Failed to POST resources\n")
        sys.exit(43)

def main():
    ci = cidetect.detect()
    if not ci:
        sys.stderr.write("No CI system reported. Please report it to <EMAIL>\n")
        sys.exit(42)

    files = xunit.detect_xunit_files(os.curdir)
    if len(files) == 0:
        sys.stdout.write("No XML test results detected\n")
        sys.exit(0)

    post(xunit_dest_url, ci, files)

if __name__ == "__main__":
    main()

{'fraction_non_alphanumeric': 0.13829357056207037, 'fraction_numerical': 0.01213101496158512, 'mean_word_length': 2.5393419170243203, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '3478672', 'n_tokens_mistral': 928, 'n_tokens_neox': 887, 'n_words': 216}