Add feature to install beta skills
# limitations under the License.
#
import gc
+import json
import os
import sys
import time
@@ -242,6 +243,22 @@ class SkillManager(Thread):
), versioned=msm_config['versioned']
)
+ @staticmethod
+ def load_skills_data() -> dict:
+ """Contains info on how skills should be updated"""
+ skills_data_file = expanduser('~/.mycroft/skills.json')
+ if isfile(skills_data_file):
+ with open(skills_data_file) as f:
+ return json.load(f)
+ else:
+ return {}
+
+ @staticmethod
+ def write_skills_data(data: dict):
+ skills_data_file = expanduser('~/.mycroft/skills.json')
+ with open(skills_data_file, 'w') as f:
+ json.dump(data, f)
+
def schedule_now(self, message=None):
self.next_download = time.time() - 1
@@ -290,8 +307,12 @@ class SkillManager(Thread):
default_names = set(chain(default_groups['default'], platform_groups))
default_skill_errored = False
+ skills_data = self.load_skills_data()
+
def install_or_update(skill):
"""Install missing defaults and update existing skills"""
+ if skills_data.get(skill.name, {}).get('beta'):
+ skill.sha = 'HEAD'
if skill.is_local:
skill.update()
if skill.name not in installed_skills:
@@ -314,6 +335,9 @@ class SkillManager(Thread):
except MsmException as e:
LOG.error('Failed to update skills: {}'.format(repr(e)))
+ for skill_name in installed_skills:
+ skills_data.setdefault(skill_name, {})['installed'] = True
+ self.write_skills_data(skills_data)
self.save_installed_skills(installed_skills)
if speak:
