Spaces:
Runtime error
Runtime error
Create cleanup.py
Browse files- cleanup.py +21 -0
cleanup.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import shutil
|
2 |
+
import os
|
3 |
+
import psutil
|
4 |
+
|
5 |
+
# 🧹 مجلدات راح تنمسح
|
6 |
+
folders_to_delete = ["./output", "./__pycache__", "./.cache", "./temp"]
|
7 |
+
|
8 |
+
print("🧹 جاري تنظيف الملفات المؤقتة...\n")
|
9 |
+
for folder in folders_to_delete:
|
10 |
+
if os.path.exists(folder):
|
11 |
+
try:
|
12 |
+
shutil.rmtree(folder)
|
13 |
+
print(f"🗑️ تم حذف: {folder}")
|
14 |
+
except Exception as e:
|
15 |
+
print(f"⚠️ ما قدر يحذف {folder}: {e}")
|
16 |
+
else:
|
17 |
+
print(f"✅ {folder} غير موجود، تجاهل.")
|
18 |
+
|
19 |
+
# 🧠 طباعة استهلاك RAM بعد التنظيف
|
20 |
+
mem = psutil.virtual_memory()
|
21 |
+
print(f"\n🧠 RAM Usage بعد التنظيف: {mem.used / 1e9:.2f} GB / {mem.total / 1e9:.2f} GB")
|