Skip to content

Commit

Permalink
fix upload_logs
Browse files Browse the repository at this point in the history
  • Loading branch information
nlef committed Oct 18, 2024
1 parent 45a6108 commit 50a36c5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
24 changes: 15 additions & 9 deletions bot/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,13 @@ def prepare_log_files() -> tuple[List[str], bool, Optional[str]]:
files = ["/boot/config.txt", "/boot/cmdline.txt", "/boot/armbianEnv.txt", "/boot/orangepiEnv.txt", "/boot/BoardEnv.txt", "/boot/env.txt"]
with open(configWrap.bot_config.log_path + "/debug.txt", mode="a", encoding="utf-8") as debug_file:
for file in files:
if Path(file).exists():
debug_file.write(f"\n{file}\n")
with open(file, mode="r", encoding="utf-8") as file_obj:
debug_file.writelines(file_obj.readlines())
try:
if Path(file).exists():
debug_file.write(f"\n{file}\n")
with open(file, mode="r", encoding="utf-8") as file_obj:
debug_file.writelines(file_obj.readlines())
except Exception as err:
logger.warning(err)

return ["telegram.log", "crowsnest.log", "moonraker.log", "klippy.log", "KlipperScreen.log", "dmesg.txt", "debug.txt"], dmesg_success, dmesg_error

Expand All @@ -370,11 +373,14 @@ async def send_logs(update: Update, _: ContextTypes.DEFAULT_TYPE) -> None:

logs_list: List[Union[InputMediaAudio, InputMediaDocument, InputMediaPhoto, InputMediaVideo]] = []
for log_file in prepare_log_files()[0]:
if Path(f"{configWrap.bot_config.log_path}/{log_file}").exists():
with open(f"{configWrap.bot_config.log_path}/{log_file}", "rb") as fh:
logs_list.append(InputMediaDocument(fh.read(), filename=log_file))
try:
if Path(f"{configWrap.bot_config.log_path}/{log_file}").exists():
with open(f"{configWrap.bot_config.log_path}/{log_file}", "rb") as fh:
logs_list.append(InputMediaDocument(fh.read(), filename=log_file))
except FileNotFoundError as err:
logger.warning(err)

await update.effective_message.reply_text(text=f"{klippy.get_versions_info()}\nUpload logs to analyzer /upload_logs", disable_notification=notifier.silent_commands, quote=True)
await update.effective_message.reply_text(text=f"{await klippy.get_versions_info()}\nUpload logs to analyzer /upload_logs", disable_notification=notifier.silent_commands, quote=True)
if logs_list:
await update.effective_message.reply_media_group(logs_list, disable_notification=notifier.silent_commands, quote=True)
else:
Expand Down Expand Up @@ -409,7 +415,7 @@ async def upload_logs(update: Update, _: ContextTypes.DEFAULT_TYPE) -> None:

with open(f"{configWrap.bot_config.log_path}/logs.tar.xz", "rb") as log_archive_ojb:
resp = httpx.post(url="https://coderus.openrepos.net/klipper_logs", files={"tarfile": log_archive_ojb}, follow_redirects=False, timeout=25)
if resp.is_success:
if resp.status_code < 400:
logs_path = resp.headers["location"]
logger.info(logs_path)
await update.effective_message.reply_text(
Expand Down
5 changes: 3 additions & 2 deletions changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
2. Переход на asyncio и актуальную версию ptb 21
3. заменена библиотека парсинга json на orjson
4. Оптимизирована работа с фото для уменьшения портребления процессора и памяти ( ценой увеличения потребления дискового пространства)
5. Сборка таймлапсов происходит с использованием системного ffmpeg. Можно менять на другой с поддержкой аппаартных ускорителей
5. Сборка таймлапсов происходит с использованием системного ffmpeg. Можно менять на другой с поддержкой аппаартных ускорителей

## Описать в документации
1. Параметры `save_lapse_photos_as_images` и `raw_compressed`
Expand All @@ -22,4 +22,5 @@
5. Описать `type` в секции `camera`
6. Описать `host_snapshot` в секции `camera`
7. Описать изменение значений `fourcc` в секции `camera`
7. Описать `limit_fps`
8. Описать `limit_fps`
9. Описать тип камеры по умолчанию `mjpeg`

0 comments on commit 50a36c5

Please sign in to comment.