#!/usr/bin/env python3 """ Clear Python cache and restart script for GPTEdit Run this script to clear all __pycache__ directories and .pyc files """ import os import shutil import sys from pathlib import Path def clear_python_cache(root_dir): """Clear all Python cache files and directories""" root_path = Path(root_dir) print(f"๐Ÿงน Clearing Python cache in: {root_path}") # Find and remove __pycache__ directories pycache_dirs = list(root_path.rglob("__pycache__")) for pycache_dir in pycache_dirs: try: shutil.rmtree(pycache_dir) print(f"โœ… Removed: {pycache_dir}") except Exception as e: print(f"โŒ Failed to remove {pycache_dir}: {e}") # Find and remove .pyc files pyc_files = list(root_path.rglob("*.pyc")) for pyc_file in pyc_files: try: pyc_file.unlink() print(f"โœ… Removed: {pyc_file}") except Exception as e: print(f"โŒ Failed to remove {pyc_file}: {e}") print(f"๐ŸŽ‰ Cache clearing complete!") if __name__ == "__main__": # Get the directory of this script script_dir = Path(__file__).parent print("=" * 50) print("GPTEdit Python Cache Cleaner") print("=" * 50) clear_python_cache(script_dir) print("\n" + "=" * 50) print("โœ… CACHE CLEARED SUCCESSFULLY!") print("Please restart your MCP server/application") print("=" * 50)