<commit_before>"""Main command module that starts the different threads."""
from ws4py.server.cherrypyserver import WebSocketPlugin
from ws4py.server.cherrypyserver import WebSocketTool
import argparse
import cherrypy
import datetime
import logging
import os
import serial
import signal
import subprocess
import sys
import threading
import time

from control.command import Command
from control.driver import Driver, STEERING_GPIO_PIN, STEERING_NEUTRAL_US, THROTTLE_GPIO_PIN, THROTTLE_NEUTRAL_US
from control.kml_waypoint_generator import KmlWaypointGenerator
from control.sup800f import switch_to_nmea_mode
from control.sup800f_telemetry import Sup800fTelemetry
from control.telemetry import Telemetry
from control.telemetry_dumper import TelemetryDumper
from control.web_telemetry.status_app import StatusApp as WebTelemetryStatusApp
from monitor.status_app import StatusApp as MonitorApp
from monitor.web_socket_logging_handler import WebSocketLoggingHandler

# pylint: disable=global-statement
# pylint: disable=broad-except

try:
    from control.button import Button
except SystemError:
    # Importing RPIO (used in button) on a non Raspberry Pi raises a
    # SystemError, so for testing on other systems, just ignore it
    print('Disabling button because not running on Raspberry Pi')
    class Dummy(object):
        def __getattr__(self, attr):
            return lambda *arg, **kwarg: None
    global Button
    Button = lambda *arg: Dummy()
    serial.Serial = lambda *arg: Dummy()
    global Driver
    Driver = lambda *arg: Dummy()

THREADS = []
POPEN = None
DRIVER = None


class CherryPyServer(threading.Thread):
    """Runs the various web apps in a thread."""
<commit_msg>Make mocks not use 100% CPU<commit_after>"""Main command module that starts the different threads."""
from ws4py.server.cherrypyserver import WebSocketPlugin
from ws4py.server.cherrypyserver import WebSocketTool
import argparse
import cherrypy
import datetime
import logging
import os
import serial
import signal
import subprocess
import sys
import threading
import time

from control.command import Command
from control.driver import Driver, STEERING_GPIO_PIN, STEERING_NEUTRAL_US, THROTTLE_GPIO_PIN, THROTTLE_NEUTRAL_US
from control.kml_waypoint_generator import KmlWaypointGenerator
from control.sup800f import switch_to_nmea_mode
from control.sup800f_telemetry import Sup800fTelemetry
from control.telemetry import Telemetry
from control.telemetry_dumper import TelemetryDumper
from control.web_telemetry.status_app import StatusApp as WebTelemetryStatusApp
from monitor.status_app import StatusApp as MonitorApp
from monitor.web_socket_logging_handler import WebSocketLoggingHandler

# pylint: disable=global-statement
# pylint: disable=broad-except

try:
    from control.button import Button
except SystemError:
    # Importing RPIO (used in button) on a non Raspberry Pi raises a
    # SystemError, so for testing on other systems, just ignore it
    print('Disabling button because not running on Raspberry Pi')
    class Dummy(object):
        def __getattr__(self, attr):
            return lambda *arg, **kwarg: time.sleep(0.01)

    global Button
    Button = lambda *arg: Dummy()
    serial.Serial = lambda *arg: Dummy()
    global Driver
    Driver = lambda *arg: Dummy()
    global Sup800fTelemetry
    Sup800fTelemetry = lambda *arg: Dummy()
    global switch_to_nmea_mode
    switch_to_nmea_mode = lambda *arg: Dummy()

THREADS = []
POPEN = None
DRIVER = None


class CherryPyServer(threading.Thread):
    """Runs the various web apps in a thread."""

{'fraction_non_alphanumeric': 0.05700645885987082, 'fraction_numerical': 0.009547879809042405, 'mean_word_length': 5.130808950086059, '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': '838391', 'n_tokens_mistral': 1052, 'n_tokens_neox': 1010, 'n_words': 353}