From 14ceb1f1dd2eb30c29093aca434aba0e5b6ab608 Mon Sep 17 00:00:00 2001 From: "Matthew D. Scholefield" Date: Mon, 14 May 2018 16:58:58 -0500 Subject: [PATCH] Remove all references to /opt/mycroft/skills The only thing that should reference it is the config --- mycroft/skills/main.py | 11 +++++----- .../integrationtests/skills/discover_tests.py | 21 +++++++++++-------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/mycroft/skills/main.py b/mycroft/skills/main.py index 6a5045412a..c93a5ef851 100644 --- a/mycroft/skills/main.py +++ b/mycroft/skills/main.py @@ -54,7 +54,6 @@ DEBUG = Configuration.get().get("debug", False) skills_config = Configuration.get().get("skills") BLACKLISTED_SKILLS = skills_config.get("blacklisted_skills", []) PRIORITY_SKILLS = skills_config.get("priority_skills", []) -SKILLS_DIR = '/opt/mycroft/skills' installer_config = Configuration.get().get("SkillInstallerSkill") @@ -202,9 +201,12 @@ class SkillManager(Thread): self.enclosure = EnclosureAPI(ws) # Schedule install/update of default skill + self.msm = self.create_msm() + self.num_install_retries = 0 + self.update_interval = Configuration.get()['skills']['update_interval'] self.update_interval = int(self.update_interval * 60 * MINUTES) - self.dot_msm = join(SKILLS_DIR, '.msm') + self.dot_msm = join(self.msm.skills_dir, '.msm') if exists(self.dot_msm): self.next_download = os.path.getmtime(self.dot_msm) + \ self.update_interval @@ -222,9 +224,6 @@ class SkillManager(Thread): ws.on('skillmanager.update', self.schedule_now) ws.on('skillmanager.list', self.send_skill_list) - self.msm = self.create_msm() - self.num_install_retries = 0 - @staticmethod def create_msm(): config = Configuration.get() @@ -432,7 +431,7 @@ class SkillManager(Thread): # Look for recently changed skill(s) needing a reload # checking skills dir and getting all skills there - skill_paths = glob(join(SKILLS_DIR, '*/')) + skill_paths = glob(join(self.msm.skills_dir, '*/')) still_loading = False for skill_path in skill_paths: still_loading = ( diff --git a/test/integrationtests/skills/discover_tests.py b/test/integrationtests/skills/discover_tests.py index ae8be154f1..e15967bd41 100644 --- a/test/integrationtests/skills/discover_tests.py +++ b/test/integrationtests/skills/discover_tests.py @@ -20,13 +20,12 @@ from os.path import exists import sys import imp +from mycroft.configuration import Configuration from test.integrationtests.skills.skill_tester import MockSkillsLoader from test.integrationtests.skills.skill_tester import SkillTest -SKILL_PATH = '/opt/mycroft/skills/' - -def discover_tests(): +def discover_tests(skills_dir): """ Find all tests for the skills in the default skill path, or in the path provided as the LAST command line argument. @@ -36,13 +35,10 @@ def discover_tests(): Returns: Tests, lists of (intent example, test environment) """ - global SKILL_PATH - if len(sys.argv) > 2: - SKILL_PATH = sys.argv.pop() tests = {} skills = [ skill for skill - in glob.glob(SKILL_PATH + '/*') + in glob.glob(skills_dir + '/*') if os.path.isdir(skill) ] @@ -66,8 +62,15 @@ def discover_tests(): return tests -tests = discover_tests() -loader = MockSkillsLoader(SKILL_PATH) +def get_skills_dir(): + if len(sys.argv) > 1: + return sys.argv[1] + return Configuration.get()['skills']['msm']['directory'] + + +skills_dir = get_skills_dir() +tests = discover_tests(skills_dir) +loader = MockSkillsLoader(skills_dir) emitter = loader.load_skills()