From 6a3b08a480654a7740efc43bd7fdb593f24992bd Mon Sep 17 00:00:00 2001 From: Daniel McKnight <34697904+NeonDaniel@users.noreply.github.com> Date: Tue, 5 Oct 2021 10:22:07 -0700 Subject: [PATCH] Refactor skills module config and online checks (#137) * Refactor skills/__main__.py Implement network check from neon_utils (0.8.1a1) Make online check optional (HolmesV compatible config) #136 * revert SkillManager import to troubleshoot test failures * Remove unused SkillManager import in __main__.py * Update neon_utils spec to stable version --- neon_core/skills/__main__.py | 36 +++++++++++++++++------------------ requirements/requirements.txt | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/neon_core/skills/__main__.py b/neon_core/skills/__main__.py index 2fb1eedc6..62c759673 100644 --- a/neon_core/skills/__main__.py +++ b/neon_core/skills/__main__.py @@ -19,26 +19,23 @@ (see setup.py) """ import time -import mycroft.lock -from neon_core.configuration import Configuration -from mycroft.util import ( - connected, - reset_sigint_handler, - start_message_bus_client, - wait_for_exit_signal -) + +from neon_core.skills.skill_manager import NeonSkillManager +from neon_core.skills.intent_service import NeonIntentService +from neon_core.skills.fallback_skill import FallbackSkill + +from neon_utils.net_utils import check_online +from neon_utils.configuration_utils import get_neon_skills_config, get_neon_lang_config + +from mycroft.lock import Lock +from mycroft.util import reset_sigint_handler, start_message_bus_client, wait_for_exit_signal from mycroft.util.lang import set_default_lang from mycroft.util.time import set_default_tz from mycroft.util.log import LOG from mycroft.util.process_utils import ProcessStatus, StatusCallbackMap - from mycroft.skills.api import SkillApi -from mycroft.skills.core import FallbackSkill from mycroft.skills.event_scheduler import EventScheduler -from mycroft.skills.skill_manager import SkillManager from mycroft.skills.msm_wrapper import MsmException -from neon_core.skills.skill_manager import NeonSkillManager -from neon_core.skills.intent_service import NeonIntentService def on_started(): @@ -65,10 +62,10 @@ def main(alive_hook=on_alive, started_hook=on_started, ready_hook=on_ready, error_hook=on_error, stopping_hook=on_stopping, watchdog=None): reset_sigint_handler() # Create PID file, prevent multiple instances of this service - mycroft.lock.Lock('skills') - config = Configuration.get() + Lock('skills') + # config = Configuration.get() # Set the active lang to match the configured one - set_default_lang(config.get('lang', 'en-us')) + set_default_lang(get_neon_lang_config().get('internal', 'en-us')) # Set the default timezone to match the configured one set_default_tz() @@ -88,7 +85,10 @@ def main(alive_hook=on_alive, started_hook=on_started, ready_hook=on_ready, skill_manager = _initialize_skill_manager(bus, watchdog) status.set_started() - _wait_for_internet_connection() + if get_neon_skills_config().get("wait_for_internet", True): + _wait_for_internet_connection() + else: + LOG.info("Online check disabled, device may be offline") if skill_manager is None: skill_manager = _initialize_skill_manager(bus, watchdog) @@ -145,7 +145,7 @@ def _initialize_skill_manager(bus, watchdog): def _wait_for_internet_connection(): - while not connected(): + while not check_online(): time.sleep(1) diff --git a/requirements/requirements.txt b/requirements/requirements.txt index d2e43761c..201549921 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -8,7 +8,7 @@ neon_audio>=0.3.2 neon_enclosure>=0.1.0 # utils -neon-utils>=0.6.0 +neon-utils>=0.9.0 rapidfuzz kthread psutil