From 9abb809070a6d456bcce25ad1375bfd54efdf832 Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Wed, 29 Sep 2021 12:16:32 -0700 Subject: [PATCH 1/4] Refactor skills/__main__.py Implement network check from neon_utils (0.8.1a1) Make online check optional (HolmesV compatible config) #136 --- neon_core/skills/__main__.py | 35 ++++++++++++++++++----------------- requirements/requirements.txt | 2 +- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/neon_core/skills/__main__.py b/neon_core/skills/__main__.py index 2fb1eedc6..b1cd6ecde 100644 --- a/neon_core/skills/__main__.py +++ b/neon_core/skills/__main__.py @@ -19,26 +19,24 @@ (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 +63,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 +86,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 +146,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..25d54e177 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.8.1a1 rapidfuzz kthread psutil From e284669f53d9f1c62ca2956838261791aa4043a6 Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Wed, 29 Sep 2021 13:49:40 -0700 Subject: [PATCH 2/4] revert SkillManager import to troubleshoot test failures --- neon_core/skills/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neon_core/skills/__main__.py b/neon_core/skills/__main__.py index b1cd6ecde..80dfb5df3 100644 --- a/neon_core/skills/__main__.py +++ b/neon_core/skills/__main__.py @@ -33,9 +33,9 @@ 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.event_scheduler import EventScheduler +from mycroft.skills.skill_manager import SkillManager from mycroft.skills.msm_wrapper import MsmException From 01d2a139990c579180455f17e7afb9c53e03b727 Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Fri, 1 Oct 2021 18:13:24 -0700 Subject: [PATCH 3/4] Remove unused SkillManager import in __main__.py --- neon_core/skills/__main__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/neon_core/skills/__main__.py b/neon_core/skills/__main__.py index 80dfb5df3..62c759673 100644 --- a/neon_core/skills/__main__.py +++ b/neon_core/skills/__main__.py @@ -35,7 +35,6 @@ from mycroft.util.process_utils import ProcessStatus, StatusCallbackMap from mycroft.skills.api import SkillApi from mycroft.skills.event_scheduler import EventScheduler -from mycroft.skills.skill_manager import SkillManager from mycroft.skills.msm_wrapper import MsmException From 6240db298adeddcd138d7cc8113100b77ac74274 Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Mon, 4 Oct 2021 09:58:50 -0700 Subject: [PATCH 4/4] Update neon_utils spec to stable version --- requirements/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 25d54e177..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.8.1a1 +neon-utils>=0.9.0 rapidfuzz kthread psutil