<commit_before># pylint: disable=C0103

import time
import threading
import queue

from .. import hat

class Routine(threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)
        self.hat = hat.Unicorn()
        self.queue = queue.Queue()
        self.status = {}
        self.just_updated = False

    def run(self):
        while True:
            try:
                data = self.queue.get_nowait()
                status = data['status'] if 'status' in data else None
            except queue.Empty:
                status = None

            self.just_updated = False
            if status:
                self.status = status
                self.just_updated = True

            self.hat.clear()
            self.update()
            self.hat.show()

            if status:
                self.queue.task_done()
            time.sleep(0.2)

    def status_to_color(self, status):
        if not status:
            return {'r':0, 'g':0, 'b':0}
        status = str(status).lower()

        if status == 'passed' or status == 'fixed':
            return {'r':0, 'g':255, 'b':0}
        if status == 'pending':
            return {'r':255, 'g':255, 'b':0}
        if status in ['failed', 'still failing', 'broken', 'errored']:
            return {'r':255, 'g':0, 'b':0}

        return {'r':0, 'g':0, 'b':255}

    def update(self):
        if self.just_updated:
            return self.hat.set_all_pixel(255, 255, 255)

        rows = {}
        interesting_branches = ['dev', 'preprod', 'prod'][::-1]<commit_msg>Avoid getting stuck on travis bad data<commit_after># pylint: disable=C0103

import time
import threading
import queue

from .. import hat

class Routine(threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)
        self.hat = hat.Unicorn()
        self.queue = queue.Queue()
        self.status = {}
        self.just_updated = False

    def run(self):
        while True:
            got_task = False

            try:
                data = self.queue.get_nowait()
                status = data['status'] if 'status' in data else None
                got_task = True
            except queue.Empty:
                status = None

            self.just_updated = False
            if status:
                self.status = status
                self.just_updated = True

            self.hat.clear()
            self.update()
            self.hat.show()

            if got_task:
                self.queue.task_done()
            time.sleep(0.2)

    def status_to_color(self, status):
        if not status:
            return {'r':0, 'g':0, 'b':0}
        status = str(status).lower()

        if status == 'passed' or status == 'fixed':
            return {'r':0, 'g':255, 'b':0}
        if status == 'pending':
            return {'r':255, 'g':255, 'b':0}
        if status in ['failed', 'still failing', 'broken', 'errored']:
            return {'r':255, 'g':0, 'b':0}

        return {'r':0, 'g':0, 'b':255}

    def update(self):
        if self.just_updated:
            return self.hat.set_all_pixel(255, 255, 255)

        rows = {}
        interesting_branches = ['dev', 'preprod', 'prod'][::-1]
{'fraction_non_alphanumeric': 0.13609281906553777, 'fraction_numerical': 0.025713389777359673, 'mean_word_length': 1.6672240802675586, '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': '7369800', 'n_tokens_mistral': 1022, 'n_tokens_neox': 939, 'n_words': 241}