Skip to content

Commit cb62bf9

Browse files
committed
standalone: config: support ENAPTER_VUCM_BLOB with deprecation warning
1 parent 954434b commit cb62bf9

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/enapter/standalone/config.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
import dataclasses
33
import enum
44
import json
5+
import logging
56
import os
67
from typing import Any, MutableMapping, Self
78

89
from enapter import mqtt
910

11+
LOGGER = logging.getLogger(__name__)
12+
1013

1114
@dataclasses.dataclass
1215
class Config:
@@ -42,7 +45,15 @@ def from_env(
4245
cls, env: MutableMapping[str, str] = os.environ, namespace: str = "ENAPTER_"
4346
) -> Self:
4447
prefix = namespace + "STANDALONE_COMMUNICATION_"
45-
blob = env[prefix + "CONFIG"]
48+
try:
49+
blob = env[namespace + "VUCM_BLOB"]
50+
LOGGER.warn(
51+
"`%s` is deprecated and will be removed soon. Please use `%s`.",
52+
namespace + "VUCM_BLOB",
53+
prefix + "CONFIG",
54+
)
55+
except KeyError:
56+
blob = env[prefix + "CONFIG"]
4657
config = cls.from_blob(blob)
4758
override_mqtt_host = env.get(prefix + "OVERRIDE_MQTT_HOST")
4859
if override_mqtt_host is not None:

0 commit comments

Comments
 (0)