Files
gpt-edit/clear_cache.py
2025-08-25 00:39:39 +09:00

54 lines
1.4 KiB
Python

#!/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)