<commit_before>from __future__ import absolute_import, print_function
import blessed
import tornado.websocket
import tornado.ioloop
import threading
import s


conns = []


def server():
    class Handler(tornado.websocket.WebSocketHandler):
        def open(self):
            conns.append(self)
        def on_close(self):
            with s.exceptions.ignore():
                conns.remote(self)
    tornado.web.Application([(r'/ws', Handler)]).listen(8888)
    tornado.ioloop.IOLoop.instance().start()


thread = threading.Thread(target=server)


def view(test_data):
    failures = [x.result for x in test_data if x.result]
    color = s.colors.red if failures else s.colors.green
    # seconds = round(sum(x.seconds for x in test_data), 3)
    name = test_data[0].path.split(':')[0]
    print(color(name))
    for failure in failures:
        print('\n'.join(failure))


def main():
    t = blessed.Terminal()
    with t.fullscreen():
        with t.hidden_cursor():
            for test_datas in s.test.run_tests_auto():
                if conns:
                    message = 'green'
                    if any(y.result for x in test_datas for y in x):
                        message = 'red'
                    for c in conns:
                        c.write_message(message)
                print(t.clear)
                with t.location(0, 0):
                    map(view, test_datas)<commit_msg>forgot to start the thread<commit_after>from __future__ import absolute_import, print_function
import blessed
import tornado.websocket
import tornado.ioloop
import threading
import s


conns = []


def server():
    class Handler(tornado.websocket.WebSocketHandler):
        def open(self):
            conns.append(self)
        def on_close(self):
            with s.exceptions.ignore():
                conns.remote(self)
    tornado.web.Application([(r'/ws', Handler)]).listen(8888)
    tornado.ioloop.IOLoop.instance().start()


def view(test_data):
    failures = [x.result for x in test_data if x.result]
    color = s.colors.red if failures else s.colors.green
    # seconds = round(sum(x.seconds for x in test_data), 3)
    name = test_data[0].path.split(':')[0]
    print(color(name))
    for failure in failures:
        print('\n'.join(failure))


def main():
    thread = threading.Thread(target=server)
    thread.daemon = True
    thread.start()

    t = blessed.Terminal()
    with t.fullscreen():
        with t.hidden_cursor():
            for test_datas in s.test.run_tests_auto():
                if conns:
                    message = 'green'
                    if any(y.result for x in test_datas for y in x):
                        message = 'red'
                    for c in conns:
                        c.write_message(message)
                print(t.clear)
                with t.location(0, 0):
                    map(view, test_datas)
{'fraction_non_alphanumeric': 0.10868055555555556, 'fraction_numerical': 0.00625, 'mean_word_length': 2.0326315789473686, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3051857', 'n_tokens_mistral': 898, 'n_tokens_neox': 842, 'n_words': 212}