-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68e8094
commit 5f4ba9c
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import subprocess | ||
import sys | ||
|
||
from telegram.ext import CommandHandler | ||
|
||
from pycamp_bot.utils import escape_markdown | ||
|
||
|
||
async def show_version(update, context): | ||
"""Let people see the details about what is being run and how""" | ||
|
||
git_rev_parse = subprocess.run(['git', 'rev-parse', '--short', 'HEAD'], capture_output=True, check=True) | ||
commit = git_rev_parse.stdout.decode().rstrip() | ||
|
||
git_diff = subprocess.run(['git', 'diff', '--quiet'], capture_output=True) | ||
if git_diff.returncode != 0: | ||
dirty_worktree = 'sí' | ||
else: | ||
dirty_worktree = 'no' | ||
|
||
python_version = '.'.join(str(component) for component in sys.version_info[:3]) | ||
|
||
pip_freeze = subprocess.run(['pip', 'freeze', '--exclude', 'PyCamp_Bot'], capture_output=True, check=True) | ||
dependencies = [] | ||
for pip_line in pip_freeze.stdout.decode().splitlines(): | ||
dependencies.append(escape_markdown(pip_line)) | ||
|
||
lines = [ | ||
f'Commit deployado: `{commit}`', | ||
f'Dirty worktree: {dirty_worktree}', | ||
f'Versión de Python: `{python_version}`', | ||
'Dependencias:', | ||
'```', | ||
*dependencies, | ||
'```', | ||
] | ||
|
||
await update.message.reply_text('\n'.join(lines), parse_mode='MarkdownV2') | ||
|
||
|
||
def set_handlers(application): | ||
application.add_handler(CommandHandler('mostrar_version', show_version)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters