Skip to content

Commit

Permalink
Refactor skills module config and online checks (#137)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
NeonDaniel authored Oct 5, 2021
1 parent 9b65240 commit 6a3b08a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
36 changes: 18 additions & 18 deletions neon_core/skills/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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()
Expand All @@ -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)
Expand Down Expand Up @@ -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)


Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6a3b08a

Please sign in to comment.