Projektarbeit-MYP/backend/scripts/run_screenshot_tool.ps1

169 lines
6.8 KiB
PowerShell

# PowerShell-Skript für automatische Screenshots
# =============================================
param(
[string]$ConfigFile = "screenshot_config.json",
[switch]$Interactive = $false,
[switch]$QuickRun = $false,
[string]$ServerUrl = "",
[string]$OutputDir = ""
)
Write-Host "===============================================" -ForegroundColor Cyan
Write-Host "🎯 AUTOMATISCHES SCREENSHOT-TOOL FÜR SCHULUNGEN" -ForegroundColor Yellow
Write-Host "===============================================" -ForegroundColor Cyan
Write-Host ""
# Arbeitsverzeichnis zum Skript-Ordner ändern
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
Set-Location $ScriptDir
# Prüfe ob Python verfügbar ist
try {
$pythonVersion = python --version 2>&1
Write-Host "✅ Python gefunden: $pythonVersion" -ForegroundColor Green
} catch {
Write-Host "❌ Python nicht gefunden!" -ForegroundColor Red
Write-Host "💡 Installieren Sie Python von https://python.org" -ForegroundColor Yellow
exit 1
}
# Prüfe ob Selenium installiert ist
$seleniumCheck = python -c "import selenium; print('✅ Selenium verfügbar')" 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host "⚠️ Selenium nicht installiert. Installiere jetzt..." -ForegroundColor Yellow
pip install selenium webdriver-manager
if ($LASTEXITCODE -ne 0) {
Write-Host "❌ Selenium-Installation fehlgeschlagen!" -ForegroundColor Red
exit 1
}
Write-Host "✅ Selenium erfolgreich installiert" -ForegroundColor Green
} else {
Write-Host $seleniumCheck -ForegroundColor Green
}
# Prüfe ChromeDriver
$chromeCheck = python -c "from selenium import webdriver; from selenium.webdriver.chrome.service import Service; print('✅ Chrome WebDriver verfügbar')" 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host "⚠️ ChromeDriver nicht gefunden. Installiere webdriver-manager..." -ForegroundColor Yellow
pip install webdriver-manager
if ($LASTEXITCODE -ne 0) {
Write-Host "❌ WebDriver-Manager-Installation fehlgeschlagen!" -ForegroundColor Red
Write-Host "💡 Manuell ChromeDriver von https://chromedriver.chromium.org/ herunterladen" -ForegroundColor Yellow
} else {
Write-Host "✅ WebDriver-Manager installiert" -ForegroundColor Green
}
}
# Flask-App verfügbarkeit prüfen
Write-Host ""
Write-Host "🔍 Prüfe Flask-App..." -ForegroundColor Blue
$flaskCheck = python -c "import sys; sys.path.append('..'); from app import app; print('✅ Flask-App verfügbar')" 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host "⚠️ Flask-App nicht direkt verfügbar" -ForegroundColor Yellow
Write-Host "📋 Das Tool wird mit Standard-Routen arbeiten" -ForegroundColor Blue
} else {
Write-Host $flaskCheck -ForegroundColor Green
}
Write-Host ""
Write-Host "🚀 STARTE SCREENSHOT-TOOL" -ForegroundColor Green
Write-Host "=" * 30 -ForegroundColor Green
# Parameter für das Python-Skript vorbereiten
$pythonArgs = @("screenshot_tool.py")
if ($QuickRun) {
Write-Host "⚡ Quick-Run-Modus aktiviert" -ForegroundColor Yellow
# Setze Umgebungsvariablen für automatische Konfiguration
$env:SCREENSHOT_AUTO_MODE = "true"
$env:SCREENSHOT_HEADLESS = "true"
if ($ServerUrl) {
$env:SCREENSHOT_SERVER_URL = $ServerUrl
}
if ($OutputDir) {
$env:SCREENSHOT_OUTPUT_DIR = $OutputDir
}
}
# Tool ausführen
try {
if ($Interactive) {
Write-Host "🎛️ Interaktiver Modus - Folgen Sie den Anweisungen" -ForegroundColor Blue
python @pythonArgs
} else {
Write-Host "🤖 Automatischer Modus" -ForegroundColor Blue
python @pythonArgs
}
$exitCode = $LASTEXITCODE
if ($exitCode -eq 0) {
Write-Host ""
Write-Host "🎉 SCREENSHOT-ERSTELLUNG ERFOLGREICH ABGESCHLOSSEN!" -ForegroundColor Green
Write-Host ""
# Zeige Ausgabe-Ordner an
$outputPath = "docs\schulung\screenshots"
if (Test-Path $outputPath) {
Write-Host "📁 Screenshots verfügbar in:" -ForegroundColor Blue
Write-Host " $(Resolve-Path $outputPath)" -ForegroundColor White
# Frage ob Ordner geöffnet werden soll
$openFolder = Read-Host "📂 Möchten Sie den Screenshot-Ordner öffnen? (j/n)"
if ($openFolder -eq "j" -or $openFolder -eq "ja" -or $openFolder -eq "y" -or $openFolder -eq "yes") {
Start-Process "explorer.exe" -ArgumentList (Resolve-Path $outputPath)
}
}
# Zeige Bericht an
$reportPath = "$outputPath\screenshot_bericht.md"
if (Test-Path $reportPath) {
Write-Host ""
Write-Host "📊 Detaillierter Bericht verfügbar:" -ForegroundColor Blue
Write-Host " $(Resolve-Path $reportPath)" -ForegroundColor White
$openReport = Read-Host "📖 Möchten Sie den Bericht öffnen? (j/n)"
if ($openReport -eq "j" -or $openReport -eq "ja" -or $openReport -eq "y" -or $openReport -eq "yes") {
Start-Process "notepad.exe" -ArgumentList (Resolve-Path $reportPath)
}
}
} else {
Write-Host ""
Write-Host "❌ FEHLER BEI DER SCREENSHOT-ERSTELLUNG" -ForegroundColor Red
Write-Host "📋 Überprüfen Sie die Logs für Details" -ForegroundColor Yellow
}
} catch {
Write-Host ""
Write-Host "❌ UNERWARTETER FEHLER: $($_.Exception.Message)" -ForegroundColor Red
$exitCode = 1
}
Write-Host ""
Write-Host "💡 VERWENDUNGSHINWEISE FÜR SCHULUNGEN:" -ForegroundColor Cyan
Write-Host "=" * 40 -ForegroundColor Cyan
Write-Host "• Admin-Screenshots: docs\schulung\screenshots\admin\" -ForegroundColor White
Write-Host "• Benutzer-Screenshots: docs\schulung\screenshots\benutzer\" -ForegroundColor White
Write-Host "• Öffentliche Screenshots: docs\schulung\screenshots\oeffentlich\" -ForegroundColor White
Write-Host "• Verschiedene Auflösungen in Unterordnern verfügbar" -ForegroundColor White
Write-Host "• Perfekt für PowerPoint-Präsentationen geeignet" -ForegroundColor White
Write-Host ""
Write-Host "🎓 TIPPS FÜR PRÄSENTATIONEN:" -ForegroundColor Yellow
Write-Host "• Desktop-Screenshots für Hauptpräsentationen verwenden" -ForegroundColor White
Write-Host "• Mobile-Screenshots für Responsive-Design zeigen" -ForegroundColor White
Write-Host "• Admin-Ordner für Administrator-Schulungen" -ForegroundColor White
Write-Host "• Benutzer-Ordner für allgemeine Mitarbeiterschulungen" -ForegroundColor White
Write-Host ""
Write-Host "📞 Bei Problemen:" -ForegroundColor Magenta
Write-Host "• Log-Datei prüfen: screenshot_tool.log" -ForegroundColor White
Write-Host "• Server läuft auf korrekter URL?" -ForegroundColor White
Write-Host "• Admin-Zugangsdaten korrekt?" -ForegroundColor White
Write-Host "• ChromeDriver installiert?" -ForegroundColor White
exit $exitCode