Files
ETPlot/refresh_gallery.py
T
2025-07-21 15:33:33 +02:00

54 lines
1.4 KiB
Python
Executable File

#!/usr/bin/env python3
"""
Simple CGI script to refresh the gallery.
Just calls the main generate_gallery.py script.
"""
import subprocess
def main():
# Output HTTP headers
print("Content-Type: text/plain")
print("Cache-Control: no-cache")
print() # Empty line to end headers
try:
# Call the gallery generation script
result = subprocess.run(
[
"python3",
"/work/kschmidt/web/generate_gallery.py"
],
capture_output=True,
text=True,
timeout=300,
)
if result.returncode == 0:
print("Gallery refresh successful!")
print("\nOutput:")
print(result.stdout)
if result.stderr:
print("\nWarnings:")
print(result.stderr)
else:
print(f"Gallery refresh failed with return code "
f"{result.returncode}")
print("\nError output:")
print(result.stderr)
if result.stdout:
print("\nStandard output:")
print(result.stdout)
except subprocess.TimeoutExpired:
print("Gallery refresh timed out after 5 minutes")
except Exception as e:
print(f"Error running gallery refresh: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
main()