예제 #1
0
 def emit(self, message):
     if message.msg_type in self.events:
         for handler in self.events[message.msg_type]:
             create_daemon(handler, (message, ))
     if message.msg_type in self.once_events:
         for handler in self.once_events[message.msg_type]:
             create_daemon(handler, (message, ))
         self.once_events.pop(message.msg_type)
예제 #2
0
 def _run(self, screen, start_scene=None):
     self.screen = screen
     create_daemon(self.refresh_loop)
     intro = self.intro()
     scenes = self.pages()
     scenes += intro
     scenes += [Scene([HelpScreen(self.screen, self)], -1, name="Help")]
     scenes += self.credits()
     self.screen.play(scenes,
                      repeat=False,
                      stop_on_resize=True,
                      start_scene=start_scene or intro[0])
예제 #3
0
 def node_setup(self):
     config = {
         "port": self.settings["port"],
         "host": self.settings["host"],
         "ssl": {
             "use_ssl": self.settings["ssl"]
         }
     }
     self.change_password(force=True)
     self.node = get_listener(bus=self.bus)
     self.node.load_config(config)
     self.node_thread = create_daemon(self.node.listen)
예제 #4
0
    def initialize(self):

        self.register_fallback(self.handle_fallback,
                               int(self.settings["priority"]))

        self.add_event("node_red.success", self.handle_node_success)
        self.add_event("node_red.intent_failure", self.handle_node_failure)
        self.add_event("node_red.converse.activate",
                       self.handle_converse_enable)
        self.add_event("node_red.converse.deactivate",
                       self.handle_converse_disable)
        self.add_event("hive.client.connection.error", self.handle_wrong_key)
        self.converse_thread = create_daemon(self.converse_keepalive)
        self.node_setup()
예제 #5
0
 def connect_to_mmost(self):
     create_daemon(self._mmost_run)
예제 #6
0
 def onOpen(self):
     super().onOpen()
     create_daemon(self.factory.start_listening)
예제 #7
0
from jarbas_utils.messagebus import send_message
from jarbas_utils.log import LOG
from jarbas_utils import create_daemon, wait_for_exit_signal
import random
from time import sleep


def alert():
    LOG.info("Alerting user of some event using Mycroft")
    send_message("speak", {"utterance": "Alert! something happened"})


def did_something_happen():
    while True:
        if random.choice([True, False]):
            alert()
        sleep(10)


create_daemon(did_something_happen) # check for something in background
wait_for_exit_signal()  # wait for ctrl+c
예제 #8
0
 def onOpen(self):
     super().onOpen()
     create_daemon(self.factory.get_cli_input)