<commit_before>import RPi.GPIO as io
import signal
import socket
import sys
import threading

from modules import logger
from modules.message_server import MessageServer

import config
import parameters


class SirenListener:
    def __init__(self):
        self.timer = None
        self.siren_message_server = MessageServer(config.siren_command_port)
        self.siren_pin = 14
        io.setmode(io.BCM)
        io.setup(self.siren_pin, io.OUT)
        io.output(self.siren_pin, io.HIGH)
        logger.logger.info('SIREN OFF!')
        self.siren_alert_duration = parameters.siren_alert_duration

    def turn_on(self, duration=parameters.siren_alert_duration):
        if self.timer is None:
            # if no timer was previously set then turn on the light
            io.output(self.siren_pin, io.LOW)
            logger.logger.info('SIREN ON!')
        else:
            # reset timer
            self.timer.cancel()
            self.timer = None

        # auto shut down the light after <duration> seconds
        self.timer = threading.Timer(duration, self.turn_off)
        self.timer.start()

    def turn_off(self):
        io.output(self.siren_pin, io.HIGH)<commit_msg>missing interuption catch in siren listener<commit_after>import RPi.GPIO as io
import signal
import socket
import sys
import threading

from modules import logger
from modules.message_server import MessageServer

import config
import parameters


class SirenListener:
    def __init__(self):
        self.timer = None
        signal.signal(signal.SIGINT, self.cleanup)
        signal.signal(signal.SIGTERM, self.cleanup)
        self.siren_message_server = MessageServer(config.siren_command_port)
        self.siren_pin = 14
        io.setmode(io.BCM)
        io.setup(self.siren_pin, io.OUT)
        io.output(self.siren_pin, io.HIGH)
        logger.logger.info('SIREN OFF!')
        self.siren_alert_duration = parameters.siren_alert_duration

    def turn_on(self, duration=parameters.siren_alert_duration):
        if self.timer is None:
            # if no timer was previously set then turn on the light
            io.output(self.siren_pin, io.LOW)
            logger.logger.info('SIREN ON!')
        else:
            # reset timer
            self.timer.cancel()
            self.timer = None

        # auto shut down the light after <duration> seconds
        self.timer = threading.Timer(duration, self.turn_off)
        self.timer.start()

    def turn_off(self):
        io.output(self.siren_pin, io.HIGH)
{'fraction_non_alphanumeric': 0.08216992421220583, 'fraction_numerical': 0.0015955325089748703, 'mean_word_length': 2.5828571428571427, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5906276', 'n_tokens_mistral': 773, 'n_tokens_neox': 740, 'n_words': 182}