<commit_before>#!/usr/bin/python3
import sys, os, subprocess, re, csv
from multiprocessing import Pool

outfile = open('output.csv', 'w')
wr = csv.writer(outfile)

def process_line(line):
    row = line.split(',')	
    server = row[0]
    servername=row[1].strip('\n')
    try:
        cmd = subprocess.check_output([os.path.dirname(sys.argv[0])+"/openssl-trace",
            "s_client", "-trace",
            "-cipher", "DHE",
            "-connect", server+":443"],
            stdin=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=1)
        for line in cmd.decode("ISO-8859-1").splitlines():
            if 'dh_p' in line:
                prime = int(re.sub(".*: ", "", line), 16)
                return '{} {} {}'.format(server, servername, prime)
     
    except subprocess.CalledProcessError:
        return ('{} {} {}'.format(server, servername, "No_DHE"))
    except subprocess.TimeoutExpired:
        return ('{} {} {}'.format(server, servername, "Can't_connect"))
    except:
        return ('{} {} [}'.format(server, servername, "Error"))
    
if __name__ == "__main__":
    workers = 50
    pool = Pool(workers)
    with open('test') as f:
        result = pool.map(process_line, f,workers)
    for item in result:
        wr.writerow([item])<commit_msg>changed file back to alexa<commit_after>#!/usr/bin/python3
import sys, os, subprocess, re, csv
from multiprocessing import Pool

outfile = open('output.csv', 'w')
wr = csv.writer(outfile)

def process_line(line):
    row = line.split(',')	
    server = row[0]
    servername=row[1].strip('\n')
    try:
        cmd = subprocess.check_output([os.path.dirname(sys.argv[0])+"/openssl-trace",
            "s_client", "-trace",
            "-cipher", "DHE",
            "-connect", server+":443"],
            stdin=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=1)
        for line in cmd.decode("ISO-8859-1").splitlines():
            if 'dh_p' in line:
                prime = int(re.sub(".*: ", "", line), 16)
                return '{} {} {}'.format(server, servername, prime)
     
    except subprocess.CalledProcessError:
        return ('{} {} {}'.format(server, servername, "No_DHE"))
    except subprocess.TimeoutExpired:
        return ('{} {} {}'.format(server, servername, "Can't_connect"))
    except:
        return ('{} {} [}'.format(server, servername, "Error"))
    
if __name__ == "__main__":
    workers = 50
    pool = Pool(workers)
    with open('alex_top1mil') as f:
        result = pool.map(process_line, f,workers)
    for item in result:
        wr.writerow([item])
{'fraction_non_alphanumeric': 0.17347335667055622, 'fraction_numerical': 0.013613380007779074, 'mean_word_length': 2.7007194244604316, 'pattern_counts': {'":': 4, '<': 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': '4512508', 'n_tokens_mistral': 856, 'n_tokens_neox': 826, 'n_words': 177}