<commit_before># Copyright (c) 2013 phrack. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import random
import threading
from threading import Thread
import time
from training_protocols.ITrainingProtocol import ITrainingProtocol 

class TimedHolsterDrill(ITrainingProtocol):
    def __init__(self, main_window, protocol_operations, targets):
        self._operations = protocol_operations

        self._operations.add_shot_list_columns(("Length",), [60])
    
        self._parent = main_window
        self._operations.get_delayed_start_interval(self._parent, self.update_interval)

        self._wait_event = threading.Event()

        self._setup_wait = Thread(target=self.setup_wait,
                                          name="setup_wait_thread")
        self._setup_wait.start()

    def update_interval(self, new_min, new_max):
        self._interval_min = new_min
        self._interval_max = new_max

    def setup_wait(self):
        # Give the shooter 10 seconds to position themselves
        self._wait_event.wait(10)
        self._operations.say("Shooter... make ready")

        self._repeat_protocol = True
        self._random_delay = Thread(target=self.random_delay,
                                          name="random_delay_thread")
        self._random_delay.start()

    def random_delay(self):
        random_delay = random.randrange(self._interval_min, self._interval_max)
        self._wait_event.wait(random_delay)

        if (self._repeat_protocol):
            self._operations.play_sound("sounds/beep.wav")
            self._beep_time = time.time()
            self.random_delay()

    def shot_listener(self, shot, shot_list_item, is_hit):<commit_msg>Timed Holster Drill now pauses shot detection until the first beep.<commit_after># Copyright (c) 2013 phrack. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import random
import threading
from threading import Thread
import time
from training_protocols.ITrainingProtocol import ITrainingProtocol 

class TimedHolsterDrill(ITrainingProtocol):
    def __init__(self, main_window, protocol_operations, targets):
        self._operations = protocol_operations

        self._operations.add_shot_list_columns(("Length",), [60])
        self._operations.pause_shot_detection(True)    

        self._parent = main_window
        self._operations.get_delayed_start_interval(self._parent, self.update_interval)

        self._wait_event = threading.Event()

        self._setup_wait = Thread(target=self.setup_wait,
                                          name="setup_wait_thread")
        self._setup_wait.start()

    def update_interval(self, new_min, new_max):
        self._interval_min = new_min
        self._interval_max = new_max

    def setup_wait(self):
        # Give the shooter 10 seconds to position themselves
        self._wait_event.wait(10)
        self._operations.say("Shooter... make ready")

        self._repeat_protocol = True
        self._random_delay = Thread(target=self.random_delay,
                                          name="random_delay_thread")
        self._random_delay.start()

    def random_delay(self):
        random_delay = random.randrange(self._interval_min, self._interval_max)
        self._wait_event.wait(random_delay)

        if (self._repeat_protocol):
            self._operations.play_sound("sounds/beep.wav")
            self._operations.pause_shot_detection(False)
            self._beep_time = time.time()
            self.random_delay()

    def shot_listener(self, shot, shot_list_item, is_hit):
{'fraction_non_alphanumeric': 0.0814173654314309, 'fraction_numerical': 0.005409791723018664, 'mean_word_length': 2.8123711340206183, '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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2489403', 'n_tokens_mistral': 1040, 'n_tokens_neox': 990, 'n_words': 225}