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

Update default configuration handling in CLI module #97

Merged
merged 4 commits into from
Feb 7, 2025
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
4 changes: 2 additions & 2 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ jobs:
timeout-minutes: 15
strategy:
matrix:
python-version: [ 3.7, 3.8, 3.9, '3.10' ]
python-version: [ 3.9, '3.10', '3.11' ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 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.
# Copyright 2008-2025 Neongecko.com Inc.
# BSD-3 License

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
Expand Down
2 changes: 1 addition & 1 deletion docker_overlay/root/run.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
# All trademark and other rights reserved by their respective owners
# Copyright 2008-2022 Neongecko.com Inc.
# Copyright 2008-2025 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
Expand Down
2 changes: 1 addition & 1 deletion neon_enclosure/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
# All trademark and other rights reserved by their respective owners
# Copyright 2008-2022 Neongecko.com Inc.
# Copyright 2008-2025 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
Expand Down
2 changes: 1 addition & 1 deletion neon_enclosure/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
# All trademark and other rights reserved by their respective owners
# Copyright 2008-2022 Neongecko.com Inc.
# Copyright 2008-2025 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
Expand Down
2 changes: 1 addition & 1 deletion neon_enclosure/admin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
# All trademark and other rights reserved by their respective owners
# Copyright 2008-2022 Neongecko.com Inc.
# Copyright 2008-2025 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
Expand Down
2 changes: 1 addition & 1 deletion neon_enclosure/admin/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
# All trademark and other rights reserved by their respective owners
# Copyright 2008-2022 Neongecko.com Inc.
# Copyright 2008-2025 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
Expand Down
2 changes: 1 addition & 1 deletion neon_enclosure/admin/service.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
# All trademark and other rights reserved by their respective owners
# Copyright 2008-2022 Neongecko.com Inc.
# Copyright 2008-2025 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
Expand Down
14 changes: 10 additions & 4 deletions neon_enclosure/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
# All trademark and other rights reserved by their respective owners
# Copyright 2008-2022 Neongecko.com Inc.
# Copyright 2008-2025 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
Expand All @@ -25,16 +25,22 @@
# 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.

import click
import sys

from os import environ
from click_default_group import DefaultGroup
from neon_utils.packaging_utils import get_package_version_spec
from neon_utils.configuration_utils import init_config_dir
from ovos_utils.log import LOG
from ovos_config.config import Configuration
from typing import List


environ.setdefault("OVOS_CONFIG_BASE_FOLDER", "neon")
environ.setdefault("OVOS_CONFIG_FILENAME", "neon.yaml")


@click.group("neon-enclosure", cls=DefaultGroup,
no_args_is_help=True, invoke_without_command=True,
help="Neon Enclosure Commands\n\n"
Expand All @@ -46,6 +52,7 @@ def neon_enclosure_cli(version: bool = False):
click.echo(f"neon_enclosure version "
f"{get_package_version_spec('neon_enclosure')}")


@neon_enclosure_cli.command(help="Install neon-enclosure module dependencies from config & cli")
@click.option("--package", "-p", default=[], multiple=True,
help="Additional package to install (can be repeated)")
Expand All @@ -58,9 +65,9 @@ def install_dependencies(package: List[str]):
LOG.info(f"pip exit code: {result}")
sys.exit(result)


@neon_enclosure_cli.command(help="Start Neon Enclosure module")
def run():
init_config_dir()
from neon_enclosure.__main__ import main
click.echo("Starting Enclosure Service")
main()
Expand All @@ -73,7 +80,6 @@ def run_admin():
if geteuid() != 0:
click.echo("Admin enclosure must be started as `root`")
exit(1)
init_config_dir()
from neon_enclosure.admin.__main__ import main
click.echo("Starting Admin Enclosure Service")
main()
Expand Down
2 changes: 1 addition & 1 deletion neon_enclosure/service.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
# All trademark and other rights reserved by their respective owners
# Copyright 2008-2022 Neongecko.com Inc.
# Copyright 2008-2025 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
Expand Down
2 changes: 1 addition & 1 deletion neon_enclosure/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
# All trademark and other rights reserved by their respective owners
# Copyright 2008-2022 Neongecko.com Inc.
# Copyright 2008-2025 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ovos-phal~=0.0,>=0.0.5
neon-utils[network]~=1.9
neon-utils[network,signal]~=1.9,>=1.12.1a1
ovos-utils~=0.0,>=0.0.32
click~=8.0
click-default-group~=1.2
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 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.
# Copyright 2008-2025 Neongecko.com Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
11 changes: 3 additions & 8 deletions tests/test_enclosure_service.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
# All trademark and other rights reserved by their respective owners
# Copyright 2008-2022 Neongecko.com Inc.
# Copyright 2008-2025 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
Expand Down Expand Up @@ -101,29 +101,24 @@ def test_enclosure_service(self):
class TestCLI(unittest.TestCase):
runner = CliRunner()

@patch("neon_enclosure.cli.init_config_dir")
@patch("neon_enclosure.__main__.main")
def test_run(self, main, init_config):
def test_run(self, main):
from neon_enclosure.cli import run
self.runner.invoke(run)
init_config.assert_called_once()
main.assert_called_once()

@patch("os.geteuid")
@patch("neon_enclosure.cli.init_config_dir")
@patch("neon_enclosure.admin.__main__.main")
def test_run_admin(self, main, init_config, get_id):
def test_run_admin(self, main, get_id):
from neon_enclosure.cli import run_admin
# Non-root
get_id.return_value = 100
self.runner.invoke(run_admin)
init_config.assert_not_called()
main.assert_not_called()

# Root
get_id.return_value = 0
self.runner.invoke(run_admin)
init_config.assert_called_once()
main.assert_called_once()


Expand Down
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 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.
# Copyright 2008-2025 Neongecko.com Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Loading