Skip to content

[FEATURE] Environment Variable Configuration Module (- WIP #31 -) #256

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

Merged
merged 4 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
29 changes: 28 additions & 1 deletion multicast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"""__package__""", """__module__""", """__name__""", """__version__""", """__prologue__""",
"""__doc__""", """exceptions""", """exceptions.CommandExecutionError""",
"""exceptions.get_exit_code_from_exception""", """exceptions.exit_on_exception""",
"""get_exit_code_from_exception""", """exit_on_exception""",
"""get_exit_code_from_exception""", """exit_on_exception""", """env""",
"""skt""", """skt.__package__""", """skt.__module__""", """skt.__name__""",
"""skt.__file__""", """skt.genSocket""", """skt.genSocket.__func__""", """genSocket""",
"""skt.endSocket""", """skt.endSocket.__func__""", """endSocket""",
Expand Down Expand Up @@ -381,6 +381,33 @@
exit_on_exception = exceptions.exit_on_exception


if 'multicast.env' not in sys.modules:
"""Import the environment configuration module.

This module provides functionality for loading and validating
multicast configuration from environment variables.
"""
# pylint: disable=cyclic-import - skipcq: PYL-R0401, PYL-C0414
from . import env # pylint: disable=cyclic-import - skipcq: PYL-R0401, PYL-C0414
else: # pragma: no branch
env = sys.modules["""multicast.env"""]

_config = env.load_config()

if _config is None:
raise ImportError("FAIL: we could not import environment. ABORT.") from None
else:
_MCAST_DEFAULT_PORT = _config["port"]
_MCAST_DEFAULT_GROUP = _config["group"]
_MCAST_DEFAULT_TTL = _config["ttl"]
global _MCAST_DEFAULT_BIND_IP # skipcq: PYL-W0604
_MCAST_DEFAULT_BIND_IP = _config["bind_addr"]
global _MCAST_DEFAULT_GROUPS # skipcq: PYL-W0604
_MCAST_DEFAULT_GROUPS = _config["groups"]
global _MCAST_DEFAULT_BUFFER # skipcq: PYL-W0604
_MCAST_DEFAULT_BUFFER = _config["buffer_size"]


class mtool(abc.ABC):
"""
Class for Multicast tools.
Expand Down
Loading
Loading