All checks were successful
ci/woodpecker/push/tests Pipeline was successful
Allows using different ways to retrieve hosts IP address
48 lines
1.1 KiB
Python
48 lines
1.1 KiB
Python
import os
|
|
import subprocess
|
|
|
|
from logging.config import dictConfig
|
|
from pathlib import Path
|
|
|
|
from dotenv import load_dotenv
|
|
from ruamel.yaml import YAML
|
|
|
|
|
|
yml = YAML(typ="safe", pure=True)
|
|
env_path = Path("..") / ".env"
|
|
|
|
load_dotenv(dotenv_path=env_path)
|
|
|
|
default_config_path = Path(__file__).resolve().parent / "logging" / "default.yml"
|
|
logging_config_path = os.environ.get("LOGGING_CONFIG", default_config_path)
|
|
|
|
with open(logging_config_path, "r") as f:
|
|
logging_config = yml.load(f.read())
|
|
dictConfig(logging_config)
|
|
|
|
|
|
def get_current_version():
|
|
if "VERSION" in os.environ:
|
|
return os.environ["VERSION"]
|
|
|
|
try:
|
|
output = subprocess.check_output(["git", "describe", "--tags"], text=True)
|
|
return output.strip()
|
|
except (subprocess.CalledProcessError, OSError):
|
|
return ""
|
|
|
|
|
|
VERSION = get_current_version()
|
|
|
|
# Optionally use sentry integration
|
|
try:
|
|
from sentry_sdk import init as sentry_init
|
|
|
|
sentry_init(
|
|
dsn=os.environ.get("SENTRY_DSN"),
|
|
environment=os.environ.get("ENVIRONMENT", "production"),
|
|
send_default_pii=False,
|
|
release=VERSION,
|
|
)
|
|
except ImportError:
|
|
pass
|