Exemple #1
0
    def __init__(self):
        self.log = create_logger()

        self.ui_block = pyee.EventEmitter()
        self.ui_dialog = pyee.EventEmitter()
        self.ui_imsg = pyee.EventEmitter()

        self._in_msg = pyee.EventEmitter()

        self._in_msg.on('block_actions', self._handle_block_actions)
        self._in_msg.on('dialog_submission', self._handle_dialog_submit)
        self._in_msg.on('interactive_message', self._handle_imsg)

        self.config = SlackAppConfig()
    def test_audio(self, file_name):
        source = FileMockMicrophone(file_name)
        ee = pyee.EventEmitter()

        class SharedData:
            times_found = 0
            found = False

        def on_found_wake_word():
            SharedData.times_found += 1

        ee.on('recognizer_loop:record_begin', on_found_wake_word)

        try:
            while True:
                self.listener.listen(source, ee)
        except EOFError:
            # Give the wake word engine some time to detect
            cnt = 0
            while cnt < 2.0:
                if SharedData.times_found > 0:
                    break
                else:
                    time.sleep(0.1)
                    cnt += 0.1

        return SharedData.times_found
Exemple #3
0
 def __init__(self):
     super().__init__()
     self.configurable = True
     self.connected_clients = set()
     self.current_state = 'initial'
     self.state_running = False
     self.state_progress = 0
     self.states = {}
     self.load_attitudes()
     self.ee = pyee.EventEmitter()
     self.ee.on('state_change', self.on_state_change)
Exemple #4
0
 def __init__(self, udp_port, tcp_host, tcp_port):
     self.ee = pyee.EventEmitter()
     self.udp_token = random.randint(0, 0x6FFFFFFF)
     self.udp_port = udp_port
     self.tcp = TCPClientManager(self, tcp_host, tcp_port)
     self.udp = UDPServerManager(self, self.udp_token, '0.0.0.0', udp_port)
     self.udp_receive_counter = 0
     self.udp_discard_counter = 0
     self.ee.on('tcp_connected', self.on_tcp_connected)
     self.ee.on('tcp_received_message', self.on_tcp_received_message)
     self.ee.on('udp_received_message', self.on_udp_received_message)
     self.ee.on('udp_discarded_message', self.on_udp_discarded_message)
Exemple #5
0
 def __init__(self):
     self.block_action = pyee.EventEmitter()
     self.dialog = pyee.EventEmitter()
     self.select = pyee.EventEmitter()
     self.imsg = pyee.EventEmitter()
     self.view = pyee.EventEmitter()
     self.view_closed = pyee.EventEmitter()
    def test_audio(self, file_name):
        source = FileMockMicrophone(file_name)
        ee = pyee.EventEmitter()

        class SharedData:
            found = False

        def on_found_wake_word():
            SharedData.found = True

        ee.on('recognizer_loop:record_begin', on_found_wake_word)

        try:
            self.listener.listen(source, ee)
        except EOFError:
            pass

        return SharedData.found
Exemple #7
0
 def __init__(self, parser: SlackAppTKParser, callback: Callable):
     self.name = parser.prog
     self.parser = parser
     self.ic = pyee.EventEmitter()
     self.cli = pyee.EventEmitter()
     self.callback = callback
Exemple #8
0
 def __init__(self, noop=False, verbose=False):
     self.noop = noop
     self.verbose = verbose
     self._now = None
     self._ee = pyee.EventEmitter()
     self._checks = None
Exemple #9
0
import mosquitto
import logging
import pyee
import json

client = None
log = logging.getLogger(__name__)
_ee = pyee.EventEmitter()


def init(host, port=1883, baseTopic='alfred', clientId=None, start=True):
    """ Configure the connection to the mqtt broker """
    global client
    client = mosquitto.Mosquitto(clientId)
    client.connected = False
    client.baseTopic = baseTopic
    client.on_message = _on_message
    client.on_connect = _on_connect
    client.on_disconnect = _on_disconnect
    client.on_subscribe = _on_subscribe

    if start:
        start_mqtt(host, port)


def on(event, f=None):
    if client:
        log.debug('subscribing to %s' % event)
        subscribe(event)
    return _ee.on(event, f)
Exemple #10
0
 def __init__(self, parser: SlackAppTKParser):
     self.name = parser.prog
     self.parser = parser
     self.ic = pyee.EventEmitter()
     self.cli = pyee.EventEmitter()