Skip to content

Instantly share code, notes, and snippets.

@forslund
Created November 26, 2020 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save forslund/cffd579e838b7e875905d6a2215965f2 to your computer and use it in GitHub Desktop.
Save forslund/cffd579e838b7e875905d6a2215965f2 to your computer and use it in GitHub Desktop.
import sys
from threading import Event
from mycroft.configuration import Configuration
from mycroft.messagebus.client import MessageBusClient
from mycroft.util import (
create_echo_function,
create_daemon,
reset_sigint_handler,
wait_for_exit_signal
)
from mycroft.util.lang import set_active_lang
from mycroft.util.log import LOG
from mycroft.skills.skill_loader import SkillLoader
def _start_messagebus_client():
"""Start the bus client daemon and wait for connection."""
bus = MessageBusClient()
Configuration.set_config_update_handlers(bus)
bus_connected = Event()
bus.on('message', create_echo_function('SKILLS'))
# Set the bus connected event when connection is established
bus.once('open', bus_connected.set)
create_daemon(bus.run_forever)
# Wait for connection
bus_connected.wait()
LOG.info('Connected to messagebus')
return bus
if __name__ == '__main__':
reset_sigint_handler()
config = Configuration.get()
# Set the active lang to match the configured one
set_active_lang(config.get('lang', 'en-us'))
bus = _start_messagebus_client()
loader = SkillLoader(bus, sys.argv[1])
skill = loader.load()
wait_for_exit_signal()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment