Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: blacklisted skills #424

Merged
merged 4 commits into from
Mar 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions ovos_core/skill_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@
from time import sleep, monotonic

from ovos_backend_client.pairing import is_paired
from ovos_bus_client.apis.enclosure import EnclosureAPI
from ovos_bus_client.client import MessageBusClient
from ovos_bus_client.message import Message
from ovos_config.config import Configuration
from ovos_config.locations import get_xdg_config_save_path
from ovos_plugin_manager.skills import find_skill_plugins
from ovos_bus_client.apis.enclosure import EnclosureAPI
from ovos_plugin_manager.skills import get_skill_directories
from ovos_utils.file_utils import FileWatcher
from ovos_utils.gui import is_gui_connected
from ovos_utils.log import LOG
from ovos_utils.network_utils import is_connected
from ovos_utils.process_utils import ProcessStatus, StatusCallbackMap, ProcessState
from ovos_plugin_manager.skills import get_skill_directories
from ovos_workshop.skill_launcher import SKILL_MAIN_MODULE
from ovos_workshop.skill_launcher import SkillLoader, PluginSkillLoader

Expand Down Expand Up @@ -126,6 +126,11 @@ def __init__(self, bus, watchdog=None, alive_hook=on_alive, started_hook=on_star
self.status.bind(self.bus)
self._init_filewatcher()

@property
def blacklist(self):
return Configuration().get("skills", {}).get("blacklisted_skills",
["skill-ovos-stop.openvoiceos"])

def _init_filewatcher(self):
# monitor skill settings files for changes
sspath = f"{get_xdg_config_save_path()}/skills/"
Expand Down Expand Up @@ -326,6 +331,10 @@ def load_plugin_skills(self, network=None, internet=None):
plugins = find_skill_plugins()
loaded_skill_ids = [basename(p) for p in self.skill_loaders]
for skill_id, plug in plugins.items():
if skill_id in self.blacklist:
LOG.warning(f"{skill_id} is blacklisted, it will NOT be loaded")
LOG.info(f"Consider uninstalling {skill_id} instead of blacklisting it")
continue
if skill_id not in self.plugin_skills and skill_id not in loaded_skill_ids:
skill_loader = self._get_plugin_skill_loader(skill_id, init_bus=False)
requirements = skill_loader.runtime_requirements
Expand Down Expand Up @@ -586,6 +595,14 @@ def _get_skill_loader(self, skill_directory, init_bus=True):
return SkillLoader(bus, skill_directory)

def _load_skill(self, skill_directory):
LOG.warning(f"Found deprecated skill directory: {skill_directory}\n"
f"please create a setup.py for this skill")
skill_id = basename(skill_directory)
if skill_id in self.blacklist:
LOG.warning(f"{skill_id} is blacklisted, it will NOT be loaded")
LOG.info(f"Consider deleting {skill_directory} instead of blacklisting it")
return None

skill_loader = self._get_skill_loader(skill_directory)
try:
load_status = skill_loader.load()
Expand All @@ -594,7 +611,7 @@ def _load_skill(self, skill_directory):
load_status = False
finally:
self.skill_loaders[skill_directory] = skill_loader

LOG.info(f"Loaded old style skill: {skill_directory}")
return skill_loader if load_status else None

def _unload_skill(self, skill_dir):
Expand Down
Loading