<commit_before>#!/usr/bin/env python

import os, sys, argparse, threading, logging
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), '../server'))
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), '../common'))
import server

def spawn_server():
    for port in range(33333, 44444):
        try:
            serv = server.TCPServer(('localhost', port), server.RequestHandler)
            serv_thread = threading.Thread(target=serv.serve_forever)
            serv_thread.daemon = True
            serv_thread.start()
            logging.info("Server running in thread: {}".format(serv_thread.name))
            return serv, port
        except OSError as e:
            logging.debug("Port {} still in use. Skipping.".format(str(port)))

def main():
    logging.basicConfig(format="%(asctime)s - %(levelname)s - %(message)s", level=logging.DEBUG)

    parser = argparse.ArgumentParser()
    parser.add_argument('-n', '--number', type=int, default=2)
    args = parser.parse_args()
    n = args.number

    # spawn server and get final port that the server is listening on
    serv, port = spawn_server()

    # spawn clients
    for x in range(n):
        cmd = 'python3 {} -c localhost {} {} >/dev/null 2>&1'.format(os.path.join(os.path.dirname(os.path.realpath(__file__)), '../client/main.py'), str(port), 'Player' + str(x))
        logging.info("Spawn client #{}: ".format(str(x), cmd))
        t = threading.Thread(target = lambda: os.system(cmd))
        t.daemon = True
        t.start()

    try:
        while True:
            pass
    except (KeyboardInterrupt, SystemExit):
        pass

    # shutdown server
    logging.info("Server shutting down...")
    serv.shutdown()
    serv.server_close()
    logging.info("Bye!")

if __name__ == '__main__':
    main()<commit_msg>[bin] Display client and server logging msgs<commit_after>#!/usr/bin/env python

import os, sys, argparse, threading, logging
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), '../server'))
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), '../common'))
import server

def spawn_server():
    for port in range(33333, 44444):
        try:
            serv = server.TCPServer(('localhost', port), server.RequestHandler)
            serv_thread = threading.Thread(target=serv.serve_forever)
            serv_thread.daemon = True
            serv_thread.start()
            logging.info("Server running in thread: {}".format(serv_thread.name))
            return serv, port
        except OSError as e:
            logging.debug("Port {} in use. Skipping.".format(str(port)))

def main():
    logging.basicConfig(format="%(asctime)s - SERVER - %(levelname)s - %(message)s", level=logging.DEBUG)

    parser = argparse.ArgumentParser()
    parser.add_argument('-n', '--number', type=int, default=2)
    args = parser.parse_args()
    n = args.number

    # spawn server and get final port that the server is listening on
    serv, port = spawn_server()
    logging.info("Server is now listening on port {}.".format(str(port)))

    # spawn clients
    for x in range(n):
        cmd = 'python3 {} -c localhost {} {}'.format(os.path.join(os.path.dirname(os.path.realpath(__file__)), '../client/main.py'), str(port), 'Player' + str(x))
        logging.info("Spawn client #{}: ".format(str(x), cmd))
        t = threading.Thread(target = lambda: os.system(cmd))
        t.daemon = True
        t.start()

    try:
        while True:
            pass
    except (KeyboardInterrupt, SystemExit):
        pass

    # shutdown server
    logging.info("Server shutting down...")
    serv.shutdown()
    serv.server_close()
    logging.info("Bye!")

if __name__ == '__main__':
    main()
{'fraction_non_alphanumeric': 0.15263718700053278, 'fraction_numerical': 0.006925945657964837, 'mean_word_length': 2.8831437435367113, 'pattern_counts': {'":': 0, '<': 3, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3980805', 'n_tokens_mistral': 1196, 'n_tokens_neox': 1161, 'n_words': 263}