diff --git a/neon_core/config.py b/neon_core/config.py index f61e1ce6f..26751ed47 100644 --- a/neon_core/config.py +++ b/neon_core/config.py @@ -28,7 +28,6 @@ from os.path import join, dirname from ovos_utils.json_helper import merge_dict -from ovos_utils.system import set_root_path from ovos_utils.xdg_utils import xdg_config_home from neon_utils.logger import LOG diff --git a/neon_core/util/runtime_utils.py b/neon_core/util/runtime_utils.py new file mode 100644 index 000000000..291c91afe --- /dev/null +++ b/neon_core/util/runtime_utils.py @@ -0,0 +1,36 @@ +# # NEON AI (TM) SOFTWARE, Software Development Kit & Application Development System +# # All trademark and other rights reserved by their respective owners +# # Copyright 2008-2021 Neongecko.com Inc. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from this +# software without specific prior written permission. +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +def use_neon_core(func): + """ + Wrapper to ensure call originates from neon_core for stack checks. + This is used for ovos-utils config platform detection which uses the stack + to determine which module config to return. + """ + def wrapper(*args, **kwargs): + return func(*args, **kwargs) + return wrapper + diff --git a/requirements/core_modules.txt b/requirements/core_modules.txt index 32dca088e..7b0442282 100644 --- a/requirements/core_modules.txt +++ b/requirements/core_modules.txt @@ -8,7 +8,7 @@ ovos-ww-plugin-pocketsphinx~=0.1.2 # neon core modules neon_enclosure~=0.1,>=0.1.2 neon_messagebus -neon_speech~=0.3,>=0.3.3a4 +neon_speech~=0.3,>=0.3.3a7 neon_audio~=0.4,>=0.4.3a4 neon_gui # TODO: Version spec GUI \ No newline at end of file diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 21a429498..99472c588 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -2,8 +2,8 @@ ovos-core[skills_lgpl]~=0.0.2a10 # utils -neon-utils~=0.12,>=0.15.1a7 -ovos_utils~=0.0.18 +neon-utils~=0.12,>=0.15.1a10 +ovos_utils~=0.0.19,>=0.0.19a3 ovos-skills-manager~=0.0.10a20 ovos-plugin-manager~=0.0.4,>=0.0.7a0 # TODO: Update to stable versions diff --git a/test/test_configuration.py b/test/test_configuration.py index fa9a6c1cb..514859ba7 100644 --- a/test/test_configuration.py +++ b/test/test_configuration.py @@ -35,18 +35,20 @@ class ConfigurationTests(unittest.TestCase): @classmethod def setUpClass(cls) -> None: - from ovos_config_assistant import config_helpers - + from ovos_config_assistant.config_helpers import \ + get_ovos_config, get_ovos_default_config_paths ovos_config = os.path.expanduser("~/.config/OpenVoiceOS/ovos.conf") if os.path.isfile(ovos_config): os.remove(ovos_config) - assert config_helpers.get_ovos_default_config_paths() == [] + assert get_ovos_default_config_paths() == [] import neon_core + from neon_core.util.runtime_utils import use_neon_core + assert isinstance(neon_core.CORE_VERSION_STR, str) - assert len(config_helpers.get_ovos_default_config_paths()) == 1 - LOG.info(config_helpers.get_ovos_default_config_paths()) - ovos_config = config_helpers.get_ovos_config() + assert len(use_neon_core(get_ovos_default_config_paths)()) == 1 + LOG.info(use_neon_core(get_ovos_default_config_paths)()) + ovos_config = use_neon_core(get_ovos_config)() LOG.info(pformat(ovos_config)) assert ovos_config['config_filename'] == 'neon.conf' @@ -54,8 +56,10 @@ def test_neon_core_config_init(self): from neon_utils.configuration_utils import \ get_mycroft_compatible_config from neon_core.configuration import Configuration + from neon_core.util.runtime_utils import use_neon_core + neon_compat_config = Configuration.get() - neon_config = get_mycroft_compatible_config() + neon_config = use_neon_core(get_mycroft_compatible_config)() for key, val in neon_config.items(): if isinstance(val, dict): for k, v in val.items(): @@ -69,8 +73,10 @@ def test_ovos_core_config_init(self): from neon_utils.configuration_utils import \ get_mycroft_compatible_config from mycroft.configuration import Configuration as MycroftConfig + from neon_core.util.runtime_utils import use_neon_core + mycroft_config = MycroftConfig.get() - neon_config = get_mycroft_compatible_config() + neon_config = use_neon_core(get_mycroft_compatible_config)() for key, val in neon_config.items(): if isinstance(val, dict): for k, v in val.items(): @@ -86,8 +92,11 @@ def test_signal_dir(self): from ovos_utils.signal import get_ipc_directory as ovos_ipc_dir from mycroft.util.signal import get_ipc_directory as mycroft_ipc_dir - self.assertEqual(neon_ipc_dir, ovos_ipc_dir()) - self.assertEqual(neon_ipc_dir, mycroft_ipc_dir()) + from neon_core.util.runtime_utils import use_neon_core + + self.assertEqual(neon_ipc_dir, use_neon_core(ovos_ipc_dir)()) + self.assertEqual(neon_ipc_dir, + use_neon_core(mycroft_ipc_dir)()) if __name__ == '__main__':