diff --git a/scripts/patch_logs_center.py b/scripts/patch_logs_center.py index c13439d..2494186 100644 --- a/scripts/patch_logs_center.py +++ b/scripts/patch_logs_center.py @@ -21,7 +21,6 @@ LOG_SOURCES = { "auto-update": {"title": "Auto Update", "kind": "journal", "unit": "virtuality-auto-update.service"}, "libvirtd": {"title": "libvirtd", "kind": "journal", "unit": "libvirtd.service"}, "virtlogd": {"title": "virtlogd", "kind": "journal", "unit": "virtlogd.service"}, - "telegram": {"title": "Telegram notifier", "kind": "file", "path": "/var/log/virtuality/telegram_version_bot.log"}, } @@ -76,7 +75,15 @@ if 'LOG_SOURCES = {' not in text: print('WARN: log helper marker not found, skip helper injection') changed.append('log center helpers skipped') else: - changed.append('log center helpers already present') + start = text.find('LOG_SOURCES = {') + end = text.find('\n}\n\n\ndef read_log_source', start) + if start != -1 and end != -1: + replacement = helpers.strip().split('\n\n\ndef read_log_source', 1)[0] + text = text[:start] + replacement + text[end + 3:] + changed.append('log sources refreshed without telegram') + else: + text = text.replace(' "telegram": {"title": "Telegram notifier", "kind": "file", "path": "/var/log/virtuality/telegram_version_bot.log"},\n', '') + changed.append('telegram log source removed') route = r''' @@ -127,7 +134,7 @@ sidebar_html = '''{% set path = request.url.path %} Обзор Создать VM
-
Образы
+ ISO Диски
@@ -152,25 +159,8 @@ if templates_dir.exists(): if '' not in html: html = html.replace('', ' \n', 1) changed.append(f'{path.name} panel.js attached') - if '{% include "_sidebar.html" %}' not in html and '
' not in html and '
' in html: - html = html.replace('\n
', '\n
\n {% include "_sidebar.html" %}\n
\n
', 1) - script_marker = '\n\n