From a98c8ee3f0292282bc8b6f794aa65f881d56c770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Delfino?= Date: Sat, 22 Jun 2024 23:41:44 -0300 Subject: [PATCH] Show if Sentry environment variable is configured in show_version --- bin/run_bot.py | 2 +- src/pycamp_bot/commands/devtools.py | 8 ++++++++ src/pycamp_bot/constants.py | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 src/pycamp_bot/constants.py diff --git a/bin/run_bot.py b/bin/run_bot.py index b03ebaf..dc0bb1e 100644 --- a/bin/run_bot.py +++ b/bin/run_bot.py @@ -13,11 +13,11 @@ from pycamp_bot.commands import schedule from pycamp_bot.commands import announcements from pycamp_bot.commands import devtools +from pycamp_bot.constants import SENTRY_DATA_SOURCE_NAME_ENVVAR from pycamp_bot.models import models_db_connection from pycamp_bot.logger import logger -SENTRY_DATA_SOURCE_NAME_ENVVAR = 'SENTRY_DATA_SOURCE_NAME' if SENTRY_DATA_SOURCE_NAME_ENVVAR in os.environ: sentry_sdk.init(dsn=os.environ[SENTRY_DATA_SOURCE_NAME_ENVVAR]) diff --git a/src/pycamp_bot/commands/devtools.py b/src/pycamp_bot/commands/devtools.py index fc2a11c..143c1b6 100644 --- a/src/pycamp_bot/commands/devtools.py +++ b/src/pycamp_bot/commands/devtools.py @@ -1,8 +1,10 @@ +import os import subprocess import sys from telegram.ext import CommandHandler +from pycamp_bot.constants import SENTRY_DATA_SOURCE_NAME_ENVVAR from pycamp_bot.utils import escape_markdown @@ -28,6 +30,11 @@ async def show_version(update, context): for pip_line in pip_freeze.stdout.decode().splitlines(): dependencies.append(escape_markdown(pip_line)) + if SENTRY_DATA_SOURCE_NAME_ENVVAR in os.environ: + sentry_envvar_set = '🟢' + else: + sentry_envvar_set = '🔴' + lines = [ f'Commit deployado: `{commit}`', f'Fecha del commit \\(author date\\): `{escape_markdown(author_date)}`', @@ -37,6 +44,7 @@ async def show_version(update, context): '```', *dependencies, '```', + f'Variable de entorno de Sentry definida: {sentry_envvar_set}', ] await update.message.reply_text('\n'.join(lines), parse_mode='MarkdownV2') diff --git a/src/pycamp_bot/constants.py b/src/pycamp_bot/constants.py new file mode 100644 index 0000000..e84cd30 --- /dev/null +++ b/src/pycamp_bot/constants.py @@ -0,0 +1 @@ +SENTRY_DATA_SOURCE_NAME_ENVVAR = 'SENTRY_DATA_SOURCE_NAME'