transip-client/transip_client/__init__.py
2021-01-02 14:40:28 +01:00

39 lines
757 B
Python

import os
import subprocess
from pathlib import Path
from dotenv import load_dotenv
env_path = Path("..") / ".env"
load_dotenv(dotenv_path=env_path)
def get_current_version():
if "VERSION" in os.environ:
return os.environ["VERSION"]
try:
output = subprocess.check_output(
["git", "describe", "--tags"], universal_newlines=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"),
send_default_pii=False,
release=VERSION,
)
except ImportError:
pass