~homeworkprod/byceps

ref: 2c36ca1dd7ac5667b5d8502ae39f59d2a17e3e00 byceps/byceps/util/system.py -rw-r--r-- 488 bytes
2c36ca1d — Jochen Kupperschmidt Use `flask.Config.from_envvar`, remove `byceps.util.system.get_config_filename_from_env[_or_exit]` 10 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""
byceps.util.system
~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2021 Jochen Kupperschmidt
:License: Revised BSD (see `LICENSE` file for details)
"""

import os

from ..config import ConfigurationError


def get_env_value(name: str, error_message: str) -> str:
    """Return the value of the environment variable.

    Raise an exception if it isn't set or if it is empty.
    """
    env = os.environ.get(name)

    if not env:
        raise ConfigurationError(error_message)

    return env