<commit_before>import serial
from serial.tools import list_ports
import contextlib
import os

DRIVER_ACK = b'ok\r\nok\r\n'
RECOVERY_TIMEOUT = 10
DEFAULT_SERIAL_TIMEOUT = 5
DEFAULT_WRITE_TIMEOUT = 30

# Note: FT232R is the board id for communication over usb on UNIX systems.
# This is set for serial communication in the Dockerfile
smoothie_id = os.environ.get('OT_SMOOTHIE_ID', 'FT232R')

ERROR_KEYWORD = b'error'
ALARM_KEYWORD = b'ALARM'


def get_ports(device_name):
    '''Returns all serial devices with a given name'''
    filtered_devices = filter(
        lambda device: device_name in device[1],
        list_ports.comports()
    )
    device_ports = [device[0] for device in filtered_devices]
    return device_ports


@contextlib.contextmanager
def serial_with_temp_timeout(serial_connection, timeout):
    '''Implements a temporary timeout for a serial connection'''
    saved_timeout = serial_connection.timeout
    if timeout is not None:
        serial_connection.timeout = timeout<commit_msg>Fix comment on env var<commit_after>import serial
from serial.tools import list_ports
import contextlib
import os

DRIVER_ACK = b'ok\r\nok\r\n'
RECOVERY_TIMEOUT = 10
DEFAULT_SERIAL_TIMEOUT = 5
DEFAULT_WRITE_TIMEOUT = 30

# Note: FT232R is the chip id for the serial-to-UART cables used to connect to
# the robot. This value will usually be correct, if using a usb-to-UART cable
# with this chip. Otherwise, set the env var to whatever identifier is used for
# the serial connection.
smoothie_id = os.environ.get('OT_SMOOTHIE_ID', 'FT232R')

ERROR_KEYWORD = b'error'
ALARM_KEYWORD = b'ALARM'


def get_ports(device_name):
    '''Returns all serial devices with a given name'''
    filtered_devices = filter(
        lambda device: device_name in device[1],
        list_ports.comports()
    )
    device_ports = [device[0] for device in filtered_devices]
    return device_ports


@contextlib.contextmanager
def serial_with_temp_timeout(serial_connection, timeout):
    '''Implements a temporary timeout for a serial connection'''
    saved_timeout = serial_connection.timeout
    if timeout is not None:
        serial_connection.timeout = timeout
{'fraction_non_alphanumeric': 0.07424593967517401, 'fraction_numerical': 0.012064965197215777, 'mean_word_length': 4.4035087719298245, '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': '2370992', 'n_tokens_mistral': 667, 'n_tokens_neox': 644, 'n_words': 213}