Skip to content

Commit

Permalink
fix/skill_launcher_locale_init (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl authored Apr 21, 2023
1 parent 3a026ec commit 011404b
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions ovos_workshop/skill_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from ovos_bus_client.message import Message
from ovos_config.config import Configuration
from ovos_config.locations import get_xdg_data_dirs, get_xdg_data_save_path
from ovos_config.locale import setup_locale
from ovos_plugin_manager.skills import find_skill_plugins
from ovos_utils import wait_for_exit_signal
from ovos_utils.file_utils import FileWatcher
Expand Down Expand Up @@ -473,10 +474,30 @@ def load(self, skill_class):
return self.loaded


def launch_plugin_skill(skill_id):
""" run a plugin skill standalone """
def _connect_to_core():
setup_locale() # ensure any initializations and resource loading is handled
bus = MessageBusClient()
bus.run_in_thread()
bus.connected_event.wait()
connected = False
while not connected:
LOG.debug("checking skills service status")
response = bus.wait_for_response(Message(f'mycroft.skills.is_ready',
context={"source": "workshop",
"destination": "skills"}))
if response and response.data['status']:
connected = True
else:
LOG.warning("ovos-core does not seem to be running")
LOG.debug("connected to core")
return bus


def launch_plugin_skill(skill_id):
""" run a plugin skill standalone """

bus = _connect_to_core()

plugins = find_skill_plugins()
if skill_id not in plugins:
raise ValueError(f"unknown skill_id: {skill_id}")
Expand All @@ -493,8 +514,9 @@ def launch_plugin_skill(skill_id):

def launch_standalone_skill(skill_directory, skill_id):
""" run a skill standalone from a directory """
bus = MessageBusClient()
bus.run_in_thread()

bus = _connect_to_core()

skill_loader = SkillLoader(bus, skill_directory,
skill_id=skill_id)
try:
Expand All @@ -508,6 +530,7 @@ def launch_standalone_skill(skill_directory, skill_id):

def _launch_script():
"""USAGE: ovos-skill-launcher {skill_id} [path/to/my/skill_id]"""

if (args_count := len(sys.argv)) == 2:
skill_id = sys.argv[1]

Expand Down

0 comments on commit 011404b

Please sign in to comment.