Merge pull request #2644 from forslund/feature/install-defaults

Always install default skills before initial load
pull/2654/head
Kris Gesling 2020-08-11 01:53:50 +00:00 committed by GitHub
commit 69a1c1d082
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View File

@ -226,6 +226,10 @@ class SkillManager(Thread):
"""Load skills and update periodically from disk and internet."""
self._remove_git_locks()
self._connected_event.wait()
if not self.skill_updater.defaults_installed():
LOG.info('Not all default skills are installed, '
'performing skill update...')
self.skill_updater.update_skills()
self._load_on_startup()
# Sync backend and skills.

View File

@ -31,6 +31,11 @@ ONE_HOUR = 3600
FIVE_MINUTES = 300 # number of seconds in a minute
def skill_is_blacklisted(skill):
blacklist = Configuration.get()['skills']['blacklisted_skills']
return os.path.basename(skill.path) in blacklist or skill.name in blacklist
class SkillUpdater:
"""Class facilitating skill update / install actions.
@ -219,6 +224,18 @@ class SkillUpdater:
raise
self.installed_skills.add(skill.name)
def defaults_installed(self):
"""Check if all default skills are installed.
Returns:
True if all default skills are installed, else False.
"""
defaults = []
for skill in self.msm.default_skills.values():
if not skill_is_blacklisted(skill):
defaults.append(skill)
return all([skill.is_local for skill in defaults])
def _get_device_skill_state(self, skill_name):
"""Get skill data structure from name."""
device_skill_state = {}