diff --git a/arena/env.py b/arena/env.py index 0705bbee..b4dd862c 100644 --- a/arena/env.py +++ b/arena/env.py @@ -4,31 +4,6 @@ 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 @@ -36,7 +11,7 @@ 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" @@ -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" @@ -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" diff --git a/arena/scene.py b/arena/scene.py index f593c8a2..054099c5 100644 --- a/arena/scene.py +++ b/arena/scene.py @@ -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, diff --git a/arena/utils/arena_telemetry.py b/arena/utils/arena_telemetry.py index cf192e0f..e480a0f8 100644 --- a/arena/utils/arena_telemetry.py +++ b/arena/utils/arena_telemetry.py @@ -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})"