debug_screenshot.py aktualisiert
This commit is contained in:
@@ -1 +1,44 @@
|
||||
OUTPUT_FILE = "/screenshots/debug_screenshot.png"
|
||||
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())
|
||||
Reference in New Issue
Block a user