Пример #1
0
 def from_env(cls):
     doors = [
         Door(
             name=door["name"],
             pin_id=door["pin_id"],
             readers=door["readers"],
         ) for door in json.loads(get_env_var('DOORS'))
     ]
     door_manager.configure(doors=doors)
     nfc_reader_manager.configure(doors=doors)
     return cls(
         master_keys=json.loads(get_env_var('MASTER_KEYS')),
         doors=doors,
         door_open_seconds=int(get_env_var('DOOR_OPEN_SECONDS')),
     )
Пример #2
0
 async def refresh_from_envs(self) -> None:
     doors = [
         Door(
             name=door["name"],
             pin_id=door["pin_id"],
             readers=door["readers"],
         ) for door in json.loads(get_env_var('DOORS'))
     ]
     door_manager.configure(doors=doors)
     nfc_reader_manager.configure(doors=doors)
Пример #3
0
def test_get_env_var(monkeypatch):
    monkeypatch.setenv("CLIENT_ID", "1")
    assert get_env_var("CLIENT_ID") == "1"
Пример #4
0
def test_get_env_var_except(monkeypatch):
    monkeypatch.delenv("CLIENT_ID", raising=False)
    with pytest.raises(ConfigError):
        get_env_var("CLIENT_ID")
Пример #5
0
def test_get_env_var_default(monkeypatch):
    monkeypatch.delenv("CLIENT_ID", raising=False)
    assert get_env_var("CLIENT_ID", default="120") is "120"
Пример #6
0
def test_get_env_var_allow_empty(monkeypatch):
    monkeypatch.delenv("CLIENT_ID", raising=False)
    assert get_env_var("CLIENT_ID", allow_empty=True) is None
Пример #7
0
def test_get_env_var_with_prefix(monkeypatch):
    monkeypatch.setenv("PRF_CLIENT_ID", "1")
    assert get_env_var("CLIENT_ID", prefix="PRF") == "1"
Пример #8
0
import logging

from nfcclient.utils import get_env_var

CLIENT_ID = get_env_var("CLIENT_ID", "1")
HUB_HOST_URL = get_env_var("HUB_HOST_URL", "https://panel.lesnahub.pl")

WEB = {
    "HOST": "localhost",
    "PORT": 8000,
}

DEBUG = False

NFC_READER_MODULE = "nfcclient.nfc_reader.nfc_reader.NFCReaderImpl"
NFC_REFRESHING_FEATURE = True
NFC_REFRESHING_FEATURE_READ_MAX = 700

READER_TIMEOUT = 0.5
READ_PERIOD = 1

try:
    from .local import *
except ImportError:  # pragma: no cover
    pass

logging.basicConfig(
    format='%(asctime)s %(levelname)-8s %(message)s',
    level=logging.DEBUG if DEBUG else logging.INFO,
    datefmt='%Y-%m-%d %H:%M:%S',
)