Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor skills module config and online checks #137

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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