#!/usr/bin/env python3 """ Example usage of BestCDN IP accessibility tester """ import asyncio import sys import os # Add src to path sys.path.insert(0, os.path.dirname(__file__)) from src.main import BestCDN async def main(): """Example usage of BestCDN""" print("BestCDN Example Usage") print("=" * 50) # Create BestCDN instance app = BestCDN() # Set test domains for each provider test_domains = { 'cloudflare': 'test10000.fstring.me', # Cloudflare test domain 'fastly': 'test10000.ix.je', # Fastly test domain 'edgeone': 'test10000.ix.je', # EdgeOne test domain 'esa': 'test10000.ix.je' # ESA test domain } print("Setting test domains...") app.set_test_domains(test_domains) # Validate setup print("Validating setup...") if not app.validate_setup(): print("\nSetup validation failed!") print("Please ensure:") print("1. IP list files exist in ip_lists/ directory") print("2. Test domains are configured") return False print("Setup validation passed!") # Run the accessibility test print("\nStarting accessibility test...") success = await app.run_accessibility_test() if success: print("\nTest completed successfully!") print("Check the 'results/' directory for output files.") else: print("\nTest failed. Check logs for details.") return success if __name__ == "__main__": try: success = asyncio.run(main()) sys.exit(0 if success else 1) except KeyboardInterrupt: print("\nTest interrupted by user") sys.exit(1) except Exception as e: print(f"Error: {e}") sys.exit(1)