Skip to content

Commit

Permalink
fix: some docs and scene check
Browse files Browse the repository at this point in the history
  • Loading branch information
nampereira committed Feb 6, 2024
1 parent 3d4146c commit 1a12c51
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 39 deletions.
56 changes: 28 additions & 28 deletions arena/env.py
Expand Up @@ -4,39 +4,14 @@
import sys
import os

MQTTH = "MQTTH"
"""
.. envvar:: MQTTH
The :envvar:`MQTTH` defines the MQTT host used by the library.
This variable overrides arguments passed in the command line.
"""

ARENA_USERNAME = "ARENA_USERNAME"
"""
.. envvar:: ARENA_USERNAME
The :envvar:`ARENA_USERNAME` defines username used to authenticate.
This variable overrides arguments passed in the command line.
"""

ARENA_PASSWORD = "ARENA_PASSWORD"
"""
.. envvar:: ARENA_PASSWORD
The :envvar:`ARENA_PASSWORD` defines password used to authenticate.
This variable overrides arguments passed in the command line.
"""

REALM = "REALM"
"""
.. envvar:: REALM
The :envvar:`REALM` defines the ARENA Realm to listen to.
After connecting, the library listens to a scene topic as follows:
`{REALM}/s/{NAMESPACE}/{SCENE}`.
This variable overrides arguments passed in the command line.
This variable overrides arguments passed in the scene's constructor.
"""

SCENE = "SCENE"
Expand All @@ -46,7 +21,7 @@
The :envvar:`SCENE` defines ARENA Scene to listen to.
After connecting, the library listens to a scene topic as follows:
`{REALM}/s/{NAMESPACE}/{SCENE}`.
This variable overrides arguments passed in the command line.
This variable overrides arguments passed in the scene's constructor.
"""

NAMESPACE = "NAMESPACE"
Expand All @@ -56,7 +31,32 @@
The :envvar:`NAMESPACE` defines ARENA Namespace to listen to.
After connecting, the library listens to a scene topic as follows:
`{REALM}/s/{NAMESPACE}/{SCENE}`.
This variable overrides arguments passed in the command line.
This variable overrides arguments passed in the scene's constructor.
"""

ARENA_USERNAME = "ARENA_USERNAME"
"""
.. envvar:: ARENA_USERNAME
The :envvar:`ARENA_USERNAME` defines username used to authenticate.
If undefined, will try to use local authentication information previously saved.
"""

ARENA_PASSWORD = "ARENA_PASSWORD"
"""
.. envvar:: ARENA_PASSWORD
The :envvar:`ARENA_PASSWORD` defines password used to authenticate.
If undefined, will try to use local authentication information previously saved.
"""

MQTTH = "MQTTH"
"""
.. envvar:: MQTTH
The :envvar:`MQTTH` defines the MQTT host used by the library.
This variable allows to use a broker different from the host argument passed to the
scene constructor
"""

DEVICE = "DEVICE"
Expand Down
5 changes: 3 additions & 2 deletions arena/scene.py
Expand Up @@ -73,13 +73,14 @@ def __init__(
self.scene = _get_env(SCENE)
print(f"Using Scene from 'SCENE' env variable: {self.scene}")
elif "scene" in kwargs and kwargs["scene"]:
if re.search("/", kwargs["scene"]):
self.exit("Scene argument (scene) cannot include '/', aborting...")
self.scene = kwargs["scene"]
print(f"Using Scene from 'scene' input parameter: {self.scene}")
else:
self.exit("Scene argument (scene) is unspecified or None, aborting...")

if re.search("/", self.scene):
self.exit("Scene cannot include '/', aborting...")

super().__init__(
host,
realm,
Expand Down
18 changes: 9 additions & 9 deletions arena/utils/arena_telemetry.py
Expand Up @@ -71,15 +71,15 @@ class ArenaTelemetry():
parent_span: Span = None

def __init__(self, name=sys.argv[0], id=None):
"""Return a `ArenaTelemetry` using given service name and id
Provides utility calls that wrap open telemetry functionality to start spans, log events, and other.
Creates a parent span for all the spans related to the program.
Args:
name: name of the service used with the telemetry backend
id: additional id used with the telemetry backend
"""
""" Return an `ArenaTelemetry` using given service name and id
Provides utility calls that wrap open telemetry functionality to start spans, log events, and other.
Creates a parent span for all the spans related to the program.
Args:
name: name of the service used with the telemetry backend
id: additional id used with the telemetry backend
"""

service_name = f"{name}"
if id: service_name = service_name + "({id})"
Expand Down

0 comments on commit 1a12c51

Please sign in to comment.