-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvscode_tab.py
More file actions
236 lines (195 loc) · 9.54 KB
/
vscode_tab.py
File metadata and controls
236 lines (195 loc) · 9.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
from base_tab import BaseTab
import tkinter as tk
from tkinter import ttk, messagebox
import subprocess
import os
import logging
import shutil
import json
class VSCodeTab(BaseTab):
def setup_ui(self):
self.pack(fill=tk.BOTH, expand=True, padx=10, pady=10)
# VS Code Eklentileri
extensions_frame = ttk.LabelFrame(self, text="VS Code Eklentileri", padding="10")
extensions_frame.pack(fill=tk.BOTH, expand=True, pady=5)
# Eklenti listesi
columns = ("Eklenti", "Yayıncı", "Sürüm", "Durum")
self.ext_list = ttk.Treeview(extensions_frame, columns=columns, show="headings")
for col in columns:
self.ext_list.heading(col, text=col)
self.ext_list.pack(fill=tk.BOTH, expand=True, pady=5)
# Git Önbellek Bilgileri
git_frame = ttk.LabelFrame(self, text="Git Önbellek Bilgileri", padding="10")
git_frame.pack(fill=tk.X, pady=5)
self.git_info = ttk.Label(git_frame, text="Git önbellek bilgileri yükleniyor...")
self.git_info.pack(anchor=tk.W, pady=5)
# Butonlar
button_frame = ttk.Frame(self)
button_frame.pack(pady=10)
ttk.Button(button_frame, text="Eklentileri Listele",
command=self.list_extensions).pack(side=tk.LEFT, padx=5)
ttk.Button(button_frame, text="Seçili Eklentiyi Kaldır",
command=self.remove_extension).pack(side=tk.LEFT, padx=5)
ttk.Button(button_frame, text="VS Code Önbelleğini Temizle",
command=self.clean_vscode_cache).pack(side=tk.LEFT, padx=5)
ttk.Button(button_frame, text="Git Önbelleğini Temizle",
command=self.clean_git_cache).pack(side=tk.LEFT, padx=5)
ttk.Button(button_frame, text="Git LFS Önbelleğini Temizle",
command=self.clean_git_lfs).pack(side=tk.LEFT, padx=5)
# İlk taramayı yap
self.list_extensions()
self.update_git_info()
def list_extensions(self):
"""VS Code eklentilerini listele"""
try:
# Listeyi temizle
for item in self.ext_list.get_children():
self.ext_list.delete(item)
# VS Code yolunu bul
vscode_paths = [
os.path.expanduser("~\\AppData\\Local\\Programs\\Microsoft VS Code\\bin\\code.cmd"),
"C:\\Program Files\\Microsoft VS Code\\bin\\code.cmd",
"C:\\Program Files (x86)\\Microsoft VS Code\\bin\\code.cmd"
]
code_path = None
for path in vscode_paths:
if os.path.exists(path):
code_path = path
break
if not code_path:
raise Exception("VS Code bulunamadı!")
# Eklentileri listele
result = subprocess.run([code_path, '--list-extensions'],
capture_output=True, text=True)
extensions = result.stdout.strip().split('\n')
for ext in extensions:
if ext:
# Her eklenti için detay al
try:
# publisher.name@version formatını parçala
parts = ext.split('.')
if len(parts) >= 2:
publisher = parts[0]
name_version = '.'.join(parts[1:]).split('@')
name = name_version[0]
version = name_version[1] if len(name_version) > 1 else "?"
self.ext_list.insert("", tk.END, values=(
name,
publisher,
version,
"✅ Aktif"
))
except:
# Hatalı format varsa en azından adını göster
self.ext_list.insert("", tk.END, values=(
ext,
"?",
"?",
"✅ Aktif"
))
except Exception as e:
logging.error(f"Eklenti listeleme hatası: {e}")
self.ext_list.insert("", tk.END, values=(
"VS Code eklentileri listelenemedi!",
"Hata",
str(e),
"❌"
))
def remove_extension(self):
"""Seçili eklentiyi kaldır"""
selected = self.ext_list.selection()
if not selected:
messagebox.showwarning("Uyarı", "Lütfen bir eklenti seçin!")
return
try:
ext_name = self.ext_list.item(selected[0])['values'][0]
publisher = self.ext_list.item(selected[0])['values'][1]
if publisher != "?" and ext_name != "VS Code eklentileri listelenemedi!":
# VS Code yolunu bul
vscode_paths = [
os.path.expanduser("~\\AppData\\Local\\Programs\\Microsoft VS Code\\bin\\code.cmd"),
"C:\\Program Files\\Microsoft VS Code\\bin\\code.cmd",
"C:\\Program Files (x86)\\Microsoft VS Code\\bin\\code.cmd"
]
code_path = None
for path in vscode_paths:
if os.path.exists(path):
code_path = path
break
if not code_path:
raise Exception("VS Code bulunamadı!")
# Eklentiyi kaldır
full_name = f"{publisher}.{ext_name}"
subprocess.run([code_path, '--uninstall-extension', full_name], check=True)
messagebox.showinfo("Başarılı", f"{full_name} eklentisi kaldırıldı!")
self.list_extensions()
else:
messagebox.showerror("Hata", "Bu öğe kaldırılamaz!")
except Exception as e:
logging.error(f"Eklenti kaldırma hatası: {e}")
messagebox.showerror("Hata", str(e))
def clean_vscode_cache(self):
"""VS Code önbelleğini temizle"""
try:
cache_paths = [
os.path.expanduser("~\\AppData\\Roaming\\Code\\Cache"),
os.path.expanduser("~\\AppData\\Roaming\\Code\\CachedData"),
os.path.expanduser("~\\AppData\\Roaming\\Code\\CachedExtensions"),
os.path.expanduser("~\\AppData\\Roaming\\Code\\Code Cache")
]
for path in cache_paths:
if os.path.exists(path):
shutil.rmtree(path)
messagebox.showinfo("Başarılı", "VS Code önbelleği temizlendi!")
except Exception as e:
logging.error(f"VS Code önbellek temizleme hatası: {e}")
messagebox.showerror("Hata", str(e))
def update_git_info(self):
"""Git önbellek bilgilerini güncelle"""
try:
# Git önbellek boyutunu hesapla
git_cache = os.path.expanduser("~\\.git")
git_lfs = os.path.expanduser("~\\.git-lfs")
git_size = self.get_folder_size(git_cache) if os.path.exists(git_cache) else 0
lfs_size = self.get_folder_size(git_lfs) if os.path.exists(git_lfs) else 0
info_text = f"Git Önbellek: {git_size/1024/1024:.1f} MB\n"
info_text += f"Git LFS Önbellek: {lfs_size/1024/1024:.1f} MB"
self.git_info.config(text=info_text)
except Exception as e:
logging.error(f"Git bilgi güncelleme hatası: {e}")
self.git_info.config(text="Git bilgileri alınamadı!")
def clean_git_cache(self):
"""Git önbelleğini temizle"""
try:
# Git'in yüklü olduğunu kontrol et
result = subprocess.run(['where', 'git'], capture_output=True, text=True)
if 'git.exe' not in result.stdout:
raise Exception("Git yüklü değil!")
# Geçerli dizinde git repo olup olmadığını kontrol et
home = os.path.expanduser("~")
os.chdir(home) # Kullanıcı dizinine geç
subprocess.run(['git', 'gc', '--aggressive', '--prune=now'], check=True)
subprocess.run(['git', 'clean', '-fdx'], check=True)
messagebox.showinfo("Başarılı", "Git önbelleği temizlendi!")
self.update_git_info()
except Exception as e:
logging.error(f"Git temizleme hatası: {e}")
messagebox.showerror("Hata", str(e))
def clean_git_lfs(self):
"""Git LFS önbelleğini temizle"""
try:
subprocess.run(['git', 'lfs', 'prune'], check=True)
messagebox.showinfo("Başarılı", "Git LFS önbelleği temizlendi!")
self.update_git_info()
except Exception as e:
logging.error(f"Git LFS temizleme hatası: {e}")
messagebox.showerror("Hata", str(e))
def get_folder_size(self, path):
"""Klasör boyutunu hesapla"""
total_size = 0
for dirpath, dirnames, filenames in os.walk(path):
for f in filenames:
fp = os.path.join(dirpath, f)
if not os.path.islink(fp):
total_size += os.path.getsize(fp)
return total_size