|
|
|
|
|
""" |
|
|
Development preview script for contributors |
|
|
Run this to generate and serve the website locally |
|
|
""" |
|
|
import os |
|
|
import sys |
|
|
import subprocess |
|
|
import webbrowser |
|
|
from pathlib import Path |
|
|
|
|
|
def main(): |
|
|
print("π§ Awesome Computational Primatology - Development Preview") |
|
|
print("=" * 60) |
|
|
|
|
|
|
|
|
if not os.path.exists("README.md"): |
|
|
print("β Error: README.md not found. Please run this from the repository root.") |
|
|
sys.exit(1) |
|
|
|
|
|
|
|
|
try: |
|
|
import pandas |
|
|
print("β
Dependencies OK") |
|
|
except ImportError: |
|
|
print("π¦ Installing pandas...") |
|
|
subprocess.run([sys.executable, "-m", "pip", "install", "pandas"]) |
|
|
|
|
|
|
|
|
print("ποΈ Generating website...") |
|
|
try: |
|
|
|
|
|
result = subprocess.run([ |
|
|
sys.executable, ".github/workflows/website.py" |
|
|
], capture_output=True, text=True) |
|
|
|
|
|
if result.returncode == 0: |
|
|
print("β
Website generated successfully") |
|
|
if result.stdout: |
|
|
print(result.stdout) |
|
|
else: |
|
|
print(f"β Error generating website:") |
|
|
print(result.stderr) |
|
|
sys.exit(1) |
|
|
except Exception as e: |
|
|
print(f"β Error running website generator: {e}") |
|
|
sys.exit(1) |
|
|
|
|
|
|
|
|
print("π Starting development server...") |
|
|
print("π± Website will open at: http://localhost:8000") |
|
|
print("π Press Ctrl+C to stop the server") |
|
|
print("-" * 60) |
|
|
|
|
|
try: |
|
|
|
|
|
webbrowser.open("http://localhost:8000") |
|
|
|
|
|
|
|
|
subprocess.run([ |
|
|
sys.executable, "-m", "http.server", "8000" |
|
|
]) |
|
|
except KeyboardInterrupt: |
|
|
print("\nπ Development server stopped") |
|
|
|
|
|
if __name__ == "__main__": |
|
|
main() |