PDF-accessibility-saas/test_env.py

61 lines
1.8 KiB
Python
Executable file

#!/usr/bin/env python3
"""
Test script to verify .env file is being loaded correctly
"""
import os
import sys
# Load environment variables from .env file (optional)
try:
from dotenv import load_dotenv
load_dotenv()
print("✅ python-dotenv loaded successfully")
except ImportError:
print("❌ python-dotenv not installed")
sys.exit(1)
print("\n" + "="*50)
print("Environment Variables from .env file")
print("="*50 + "\n")
# Check Anthropic API Key
anthropic_key = os.getenv('ANTHROPIC_API_KEY')
if anthropic_key:
print(f"✅ ANTHROPIC_API_KEY: {anthropic_key[:20]}...{anthropic_key[-10:]}")
else:
print("❌ ANTHROPIC_API_KEY: Not set")
# Check Google API Key
google_api_key = os.getenv('GOOGLE_API_KEY')
if google_api_key:
print(f"✅ GOOGLE_API_KEY: {google_api_key[:20]}...{google_api_key[-10:]}")
else:
print("⚠️ GOOGLE_API_KEY: Not set (optional)")
# Check Google Credentials Path
google_creds = os.getenv('GOOGLE_APPLICATION_CREDENTIALS')
if google_creds:
if os.path.isfile(google_creds):
print(f"✅ GOOGLE_APPLICATION_CREDENTIALS: {google_creds} (file exists)")
else:
print(f"⚠️ GOOGLE_APPLICATION_CREDENTIALS: {google_creds} (file NOT found)")
else:
print("⚠️ GOOGLE_APPLICATION_CREDENTIALS: Not set (optional)")
print("\n" + "="*50)
print("Summary")
print("="*50 + "\n")
if anthropic_key:
print("✅ Configuration looks good!")
print(" - Anthropic API key is configured")
if google_api_key or (google_creds and os.path.isfile(google_creds)):
print(" - Google Cloud Vision is configured")
else:
print(" - Google Cloud Vision not configured (optional)")
else:
print("❌ Missing required configuration!")
print(" - Edit .env file and add ANTHROPIC_API_KEY")
print()