Created
November 26, 2020 06:41
-
-
Save forslund/cffd579e838b7e875905d6a2215965f2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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