File size: 1,960 Bytes
74adcb4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
#!/usr/bin/env python3
"""
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)
# Check if we're in the right directory
if not os.path.exists("README.md"):
print("โ Error: README.md not found. Please run this from the repository root.")
sys.exit(1)
# Check for required dependencies
try:
import pandas
print("โ
Dependencies OK")
except ImportError:
print("๐ฆ Installing pandas...")
subprocess.run([sys.executable, "-m", "pip", "install", "pandas"])
# Generate website
print("๐๏ธ Generating website...")
try:
# Run the website.py script directly
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)
# Start server
print("๐ Starting development server...")
print("๐ฑ Website will open at: http://localhost:8000")
print("๐ Press Ctrl+C to stop the server")
print("-" * 60)
try:
# Open browser
webbrowser.open("http://localhost:8000")
# Start server
subprocess.run([
sys.executable, "-m", "http.server", "8000"
])
except KeyboardInterrupt:
print("\n๐ Development server stopped")
if __name__ == "__main__":
main() |