clearml-server/apiserver/utilities/env.py
allegroai 02933a9c93 Support disabling response compression
Return fixed server header
2022-03-15 16:21:14 +02:00

15 lines
396 B
Python

from distutils.util import strtobool
from os import getenv
from typing import Optional
def get_bool(*keys: str, default: bool = None) -> Optional[bool]:
try:
value = next(env for env in (getenv(key) for key in keys) if env is not None)
except StopIteration:
return default
try:
return bool(strtobool(value))
except ValueError:
return bool(value)