From 411fcf04202751ef611d9168560425010e320802 Mon Sep 17 00:00:00 2001 From: Floke Date: Sat, 5 Jul 2025 17:32:14 +0000 Subject: [PATCH] debug_screenshot.py aktualisiert --- debug_screenshot.py | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/debug_screenshot.py b/debug_screenshot.py index c3a78613..6870c6c1 100644 --- a/debug_screenshot.py +++ b/debug_screenshot.py @@ -1 +1,44 @@ -OUTPUT_FILE = "/screenshots/debug_screenshot.png" \ No newline at end of file +import asyncio +from pyppeteer import launch +import logging + +# Logging-Konfiguration +logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') + +HA_URL = "http://192.168.178.131:8123/lovelace/solar?kiosk" +OUTPUT_FILE = "/app/output/debug_screenshot.png" + +async def main(): + logging.info("Starte Puppeteer-Browser...") + browser = await launch( + executablePath='/usr/bin/chromium-browser', + headless=True, + args=['--no-sandbox', '--disable-setuid-sandbox'] + ) + + page = await browser.newPage() + await page.setViewport({'width': 1280, 'height': 1024}) + + try: + logging.info(f"Navigiere zu URL: {HA_URL}") + # Wir erhöhen den Timeout auf 60 Sekunden + await page.goto(HA_URL, {'waitUntil': 'networkidle0', 'timeout': 60000}) + + logging.info("Seite geladen. Warte 10 Sekunden, um Rendering abzuwarten...") + await asyncio.sleep(10) + + logging.info("Erstelle Screenshot...") + await page.screenshot({'path': OUTPUT_FILE}) + logging.info(f"Screenshot erfolgreich unter {OUTPUT_FILE} gespeichert.") + + except Exception as e: + logging.error(f"Ein Fehler ist aufgetreten: {e}") + logging.info("Speichere trotzdem einen Screenshot des aktuellen Zustands...") + await page.screenshot({'path': '/app/output/debug_error.png'}) + + finally: + logging.info("Schließe Browser.") + await browser.close() + +if __name__ == '__main__': + asyncio.run(main()) \ No newline at end of file