<commit_before>#!/usr/bin/python3.4
import requests
import json
import time
def test_plenty_sha256(filename):
    sha256_list = get_sha256_list(filename)
    for sha256 in sha256_list:
        time.sleep(1)
        payload = {'sha256': sha256}
        response = requests.post('http://localhost:5005/api/singleVirusTotal',
                                 data=json.dumps(payload))

    for sha256 in sha256_list:
        payload = {'sha256': sha256}
        response = requests.post('http://localhost:5005/api/virus',
                                 data=json.dumps(payload))
        write_to_file(sha256, str(response.json()))

def write_to_file(sha256, text):
    with open("results/" + sha256 + ".json", 'w+') as file:
        file.write(text)

def get_sha256_list(filename):
    sha256_list = []
    with open(filename) as file:
        for line in file:
            splitted_tab = line.split(" ")
            sha256 = splitted_tab[0]
            sha256_list.append(sha256)
    return sha256_list

test_plenty_sha256("locky.txt")
test_plenty_sha256("crypto.txt")<commit_msg>added comment<commit_after>#!/usr/bin/python3.4
import requests
import json
import time

# żeby zadziałało najpierw należy uruchomić serwer na porcie 5005
def test_plenty_sha256(filename):
    sha256_list = get_sha256_list(filename)
    for sha256 in sha256_list:
        time.sleep(1)
        payload = {'sha256': sha256}
        response = requests.post('http://localhost:5005/api/singleVirusTotal',
                                 data=json.dumps(payload))

    for sha256 in sha256_list:
        payload = {'sha256': sha256}
        response = requests.post('http://localhost:5005/api/virus',
                                 data=json.dumps(payload))
        write_to_file(sha256, str(response.json()))

def write_to_file(sha256, text):
    with open("results/" + sha256 + ".json", 'w+') as file:
        file.write(text)

def get_sha256_list(filename):
    sha256_list = []
    with open(filename) as file:
        for line in file:
            splitted_tab = line.split(" ")
            sha256 = splitted_tab[0]
            sha256_list.append(sha256)
    return sha256_list

test_plenty_sha256("crypto.txt")
test_plenty_sha256("locky.txt")
{'fraction_non_alphanumeric': 0.11540188594521779, 'fraction_numerical': 0.07184553210597217, 'mean_word_length': 2.646481178396072, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3810266', 'n_tokens_mistral': 815, 'n_tokens_neox': 710, 'n_words': 139}