import logging from functools import partial from io import StringIO import gradio as gr from apscheduler.schedulers.background import BackgroundScheduler from bs4 import BeautifulSoup from rich.console import Console from rich.syntax import Syntax from src.backend import backend_routine from src.logging import configure_root_logger, log_file, setup_logger logging.getLogger("httpx").setLevel(logging.WARNING) logging.getLogger("numexpr").setLevel(logging.WARNING) logging.getLogger("absl").setLevel(logging.WARNING) configure_root_logger() logging.basicConfig(level=logging.INFO) logger = setup_logger(__name__) def log_file_to_html_string(reverse=True): with open(log_file, "rt") as f: lines = f.readlines() lines = lines[-300:] if reverse: lines = reversed(lines) output = "".join(lines) syntax = Syntax(output, "python", theme="monokai", word_wrap=True) console = Console(record=True, width=150, style="#272822", file=StringIO()) console.print(syntax) html_content = console.export_html(inline_styles=True) # Parse the HTML content using BeautifulSoup soup = BeautifulSoup(html_content, "lxml") # Modify the
tag and add custom styles pre_tag = soup.pre pre_tag["class"] = "scrollable" del pre_tag["style"] # Add your custom styles and the .scrollable CSS to the