clapp-pm 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
dependency_resolver.py ADDED
@@ -0,0 +1,272 @@
1
+ import os
2
+ from package_registry import get_manifest, app_exists
3
+
4
+ def check_dependencies(manifest):
5
+ """
6
+ Manifest'te belirtilen bağımlılıkları kontrol eder.
7
+
8
+ Args:
9
+ manifest (dict): Kontrol edilecek manifest
10
+
11
+ Returns:
12
+ list: Eksik bağımlılıkların listesi
13
+ """
14
+ missing_dependencies = []
15
+
16
+ # Bağımlılık listesini al
17
+ dependencies = manifest.get('dependencies', [])
18
+
19
+ if not dependencies:
20
+ return missing_dependencies
21
+
22
+ # Her bağımlılığı kontrol et
23
+ for dependency in dependencies:
24
+ if not app_exists(dependency):
25
+ missing_dependencies.append(dependency)
26
+
27
+ return missing_dependencies
28
+
29
+ def check_app_dependencies(app_name):
30
+ """
31
+ Belirtilen uygulamanın bağımlılıklarını kontrol eder.
32
+
33
+ Args:
34
+ app_name (str): Kontrol edilecek uygulama adı
35
+
36
+ Returns:
37
+ tuple: (missing_dependencies: list, dependency_info: dict)
38
+ """
39
+ # Uygulama manifest'ini al
40
+ manifest = get_manifest(app_name)
41
+
42
+ if not manifest:
43
+ return [], {"error": f"Uygulama '{app_name}' bulunamadı"}
44
+
45
+ # Bağımlılıkları kontrol et
46
+ missing_dependencies = check_dependencies(manifest)
47
+
48
+ # Bağımlılık bilgilerini topla
49
+ dependency_info = {
50
+ "app_name": app_name,
51
+ "total_dependencies": len(manifest.get('dependencies', [])),
52
+ "missing_count": len(missing_dependencies),
53
+ "satisfied_count": len(manifest.get('dependencies', [])) - len(missing_dependencies),
54
+ "dependencies": manifest.get('dependencies', []),
55
+ "missing_dependencies": missing_dependencies
56
+ }
57
+
58
+ return missing_dependencies, dependency_info
59
+
60
+ def get_dependency_tree(app_name, visited=None):
61
+ """
62
+ Uygulamanın bağımlılık ağacını oluşturur.
63
+
64
+ Args:
65
+ app_name (str): Uygulama adı
66
+ visited (set): Ziyaret edilen uygulamalar (döngüsel bağımlılık kontrolü için)
67
+
68
+ Returns:
69
+ dict: Bağımlılık ağacı
70
+ """
71
+ if visited is None:
72
+ visited = set()
73
+
74
+ # Döngüsel bağımlılık kontrolü
75
+ if app_name in visited:
76
+ return {"error": f"Döngüsel bağımlılık tespit edildi: {app_name}"}
77
+
78
+ visited.add(app_name)
79
+
80
+ # Uygulama manifest'ini al
81
+ manifest = get_manifest(app_name)
82
+
83
+ if not manifest:
84
+ return {"error": f"Uygulama '{app_name}' bulunamadı"}
85
+
86
+ # Bağımlılık ağacını oluştur
87
+ tree = {
88
+ "name": app_name,
89
+ "version": manifest.get('version', '0.0.0'),
90
+ "language": manifest.get('language', 'unknown'),
91
+ "dependencies": [],
92
+ "missing_dependencies": []
93
+ }
94
+
95
+ dependencies = manifest.get('dependencies', [])
96
+
97
+ for dep in dependencies:
98
+ if app_exists(dep):
99
+ # Bağımlılığın kendi ağacını al
100
+ dep_tree = get_dependency_tree(dep, visited.copy())
101
+ tree["dependencies"].append(dep_tree)
102
+ else:
103
+ tree["missing_dependencies"].append(dep)
104
+
105
+ return tree
106
+
107
+ def resolve_all_dependencies(app_name):
108
+ """
109
+ Uygulamanın tüm bağımlılıklarını çözümler (derin analiz).
110
+
111
+ Args:
112
+ app_name (str): Uygulama adı
113
+
114
+ Returns:
115
+ dict: Çözümleme sonuçları
116
+ """
117
+ result = {
118
+ "app_name": app_name,
119
+ "status": "unknown",
120
+ "all_dependencies": set(),
121
+ "missing_dependencies": set(),
122
+ "dependency_tree": None,
123
+ "circular_dependencies": [],
124
+ "resolution_order": []
125
+ }
126
+
127
+ # Bağımlılık ağacını al
128
+ tree = get_dependency_tree(app_name)
129
+ result["dependency_tree"] = tree
130
+
131
+ if "error" in tree:
132
+ result["status"] = "error"
133
+ return result
134
+
135
+ # Tüm bağımlılıkları topla
136
+ def collect_dependencies(node, all_deps, missing_deps):
137
+ if "dependencies" in node:
138
+ for dep in node["dependencies"]:
139
+ all_deps.add(dep["name"])
140
+ collect_dependencies(dep, all_deps, missing_deps)
141
+
142
+ if "missing_dependencies" in node:
143
+ for missing in node["missing_dependencies"]:
144
+ missing_deps.add(missing)
145
+
146
+ collect_dependencies(tree, result["all_dependencies"], result["missing_dependencies"])
147
+
148
+ # Durum belirleme
149
+ if result["missing_dependencies"]:
150
+ result["status"] = "missing_dependencies"
151
+ else:
152
+ result["status"] = "resolved"
153
+
154
+ # Çözümleme sırası (topological sort benzeri)
155
+ result["resolution_order"] = list(result["all_dependencies"])
156
+
157
+ return result
158
+
159
+ def get_dependency_report(app_name):
160
+ """
161
+ Bağımlılık raporu oluşturur.
162
+
163
+ Args:
164
+ app_name (str): Uygulama adı
165
+
166
+ Returns:
167
+ str: Formatlanmış bağımlılık raporu
168
+ """
169
+ missing_deps, dep_info = check_app_dependencies(app_name)
170
+
171
+ if "error" in dep_info:
172
+ return f"❌ Hata: {dep_info['error']}"
173
+
174
+ report = f"📦 {app_name} Bağımlılık Raporu\n"
175
+ report += "=" * 40 + "\n"
176
+
177
+ if dep_info["total_dependencies"] == 0:
178
+ report += "✅ Bu uygulama hiçbir bağımlılığa sahip değil.\n"
179
+ return report
180
+
181
+ report += f"📊 Toplam Bağımlılık: {dep_info['total_dependencies']}\n"
182
+ report += f"✅ Karşılanan: {dep_info['satisfied_count']}\n"
183
+ report += f"❌ Eksik: {dep_info['missing_count']}\n\n"
184
+
185
+ if missing_deps:
186
+ report += "🚨 Eksik Bağımlılıklar:\n"
187
+ for dep in missing_deps:
188
+ report += f" - {dep}\n"
189
+ report += "\n"
190
+
191
+ if dep_info["satisfied_count"] > 0:
192
+ satisfied_deps = [dep for dep in dep_info["dependencies"] if dep not in missing_deps]
193
+ report += "✅ Karşılanan Bağımlılıklar:\n"
194
+ for dep in satisfied_deps:
195
+ dep_manifest = get_manifest(dep)
196
+ version = dep_manifest.get('version', '0.0.0') if dep_manifest else 'bilinmiyor'
197
+ report += f" - {dep} (v{version})\n"
198
+ report += "\n"
199
+
200
+ return report
201
+
202
+ def check_system_dependencies():
203
+ """
204
+ Sistemdeki tüm uygulamaların bağımlılıklarını kontrol eder.
205
+
206
+ Returns:
207
+ dict: Sistem geneli bağımlılık durumu
208
+ """
209
+ from package_registry import list_packages
210
+
211
+ packages = list_packages()
212
+ system_report = {
213
+ "total_apps": len(packages),
214
+ "apps_with_dependencies": 0,
215
+ "apps_with_missing_dependencies": 0,
216
+ "total_dependencies": 0,
217
+ "total_missing": 0,
218
+ "problematic_apps": []
219
+ }
220
+
221
+ for package in packages:
222
+ app_name = package['name']
223
+ missing_deps, dep_info = check_app_dependencies(app_name)
224
+
225
+ if dep_info["total_dependencies"] > 0:
226
+ system_report["apps_with_dependencies"] += 1
227
+ system_report["total_dependencies"] += dep_info["total_dependencies"]
228
+
229
+ if missing_deps:
230
+ system_report["apps_with_missing_dependencies"] += 1
231
+ system_report["total_missing"] += len(missing_deps)
232
+ system_report["problematic_apps"].append({
233
+ "name": app_name,
234
+ "missing_dependencies": missing_deps
235
+ })
236
+
237
+ return system_report
238
+
239
+ def get_system_dependency_report():
240
+ """
241
+ Sistem geneli bağımlılık raporu oluşturur.
242
+
243
+ Returns:
244
+ str: Formatlanmış sistem raporu
245
+ """
246
+ report_data = check_system_dependencies()
247
+
248
+ report = "🏢 Sistem Bağımlılık Raporu\n"
249
+ report += "=" * 40 + "\n"
250
+
251
+ report += f"📱 Toplam Uygulama: {report_data['total_apps']}\n"
252
+ report += f"🔗 Bağımlılığa Sahip: {report_data['apps_with_dependencies']}\n"
253
+ report += f"⚠️ Eksik Bağımlılığa Sahip: {report_data['apps_with_missing_dependencies']}\n"
254
+ report += f"📊 Toplam Bağımlılık: {report_data['total_dependencies']}\n"
255
+ report += f"❌ Toplam Eksik: {report_data['total_missing']}\n\n"
256
+
257
+ if report_data['problematic_apps']:
258
+ report += "🚨 Sorunlu Uygulamalar:\n"
259
+ for app in report_data['problematic_apps']:
260
+ report += f" 📦 {app['name']}:\n"
261
+ for dep in app['missing_dependencies']:
262
+ report += f" - {dep}\n"
263
+ report += "\n"
264
+ else:
265
+ report += "✅ Tüm bağımlılıklar karşılanmış!\n"
266
+
267
+ return report
268
+
269
+ if __name__ == "__main__":
270
+ # Test için örnek kullanım
271
+ print("Sistem bağımlılık raporu:")
272
+ print(get_system_dependency_report())
doctor_command.py ADDED
@@ -0,0 +1,279 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ doctor_command.py - Kapsamlı sistem tanılaması modülü
4
+
5
+ Bu modül `clapp doctor` komutunu destekler ve sistemin
6
+ clapp için uygun olup olmadığını kapsamlı şekilde kontrol eder.
7
+ """
8
+
9
+ import os
10
+ import sys
11
+ import shutil
12
+ import platform
13
+ import subprocess
14
+ from pathlib import Path
15
+ from check_env import (
16
+ check_python_version,
17
+ check_clapp_in_path,
18
+ check_platform_info,
19
+ check_python_executable,
20
+ check_working_directory,
21
+ check_apps_directory,
22
+ check_permissions,
23
+ check_flet_installation
24
+ )
25
+
26
+ def check_clapp_config():
27
+ """clapp konfigürasyon dizinini kontrol eder"""
28
+ home = Path.home()
29
+ clapp_config_dir = home / ".clapp"
30
+
31
+ if clapp_config_dir.exists():
32
+ return True, f"Konfigürasyon dizini mevcut: {clapp_config_dir}"
33
+ else:
34
+ return False, "Konfigürasyon dizini bulunamadı (~/.clapp)"
35
+
36
+ def check_path_environment():
37
+ """PATH ortam değişkenini detaylı kontrol eder"""
38
+ path_env = os.environ.get("PATH", "")
39
+ path_dirs = path_env.split(os.pathsep)
40
+
41
+ # Önemli dizinleri kontrol et
42
+ important_dirs = []
43
+
44
+ # Platform'a göre önemli dizinler
45
+ system = platform.system().lower()
46
+ if system == "windows":
47
+ important_dirs = [
48
+ os.path.join(os.environ.get("APPDATA", ""), "Python", "Scripts"),
49
+ os.path.join(sys.prefix, "Scripts"),
50
+ ]
51
+ else:
52
+ home = Path.home()
53
+ important_dirs = [
54
+ str(home / ".local" / "bin"),
55
+ "/usr/local/bin",
56
+ "/usr/bin",
57
+ ]
58
+
59
+ found_dirs = []
60
+ missing_dirs = []
61
+
62
+ for imp_dir in important_dirs:
63
+ if imp_dir in path_dirs:
64
+ found_dirs.append(imp_dir)
65
+ else:
66
+ missing_dirs.append(imp_dir)
67
+
68
+ if missing_dirs:
69
+ return False, f"PATH'te eksik dizinler: {', '.join(missing_dirs)}"
70
+ else:
71
+ return True, f"PATH uygun ({len(found_dirs)} önemli dizin mevcut)"
72
+
73
+ def check_dependencies():
74
+ """Bağımlılıkları kontrol eder"""
75
+ dependencies = ["python", "pip"]
76
+
77
+ missing = []
78
+ found = []
79
+
80
+ for dep in dependencies:
81
+ if shutil.which(dep):
82
+ found.append(dep)
83
+ else:
84
+ missing.append(dep)
85
+
86
+ if missing:
87
+ return False, f"Eksik bağımlılıklar: {', '.join(missing)}"
88
+ else:
89
+ return True, f"Tüm bağımlılıklar mevcut: {', '.join(found)}"
90
+
91
+ def check_disk_space():
92
+ """Disk alanını kontrol eder"""
93
+ try:
94
+ cwd = Path.cwd()
95
+ stat = shutil.disk_usage(cwd)
96
+
97
+ # GB'ye çevir
98
+ free_gb = stat.free / (1024**3)
99
+ total_gb = stat.total / (1024**3)
100
+
101
+ if free_gb < 0.5: # 500MB'den az
102
+ return False, f"Yetersiz disk alanı: {free_gb:.1f}GB boş"
103
+ else:
104
+ return True, f"Disk alanı uygun: {free_gb:.1f}GB / {total_gb:.1f}GB"
105
+
106
+ except Exception as e:
107
+ return False, f"Disk alanı kontrol edilemedi: {str(e)}"
108
+
109
+ def check_network_access():
110
+ """Ağ erişimini kontrol eder"""
111
+ try:
112
+ # Basit bir ping testi
113
+ import socket
114
+ socket.create_connection(("8.8.8.8", 53), timeout=3)
115
+ return True, "Ağ erişimi mevcut"
116
+ except:
117
+ return False, "Ağ erişimi yok veya sınırlı"
118
+
119
+ def check_installed_apps():
120
+ """Yüklü uygulamaları kontrol eder"""
121
+ try:
122
+ from package_registry import list_packages
123
+ packages = list_packages()
124
+
125
+ if not packages:
126
+ return True, "Yüklü uygulama yok (normal)"
127
+
128
+ # Bozuk uygulamaları kontrol et
129
+ broken_apps = []
130
+ for package in packages:
131
+ if not package.get("name") or not package.get("entry"):
132
+ broken_apps.append(package.get("name", "Bilinmiyor"))
133
+
134
+ if broken_apps:
135
+ return False, f"Bozuk uygulamalar: {', '.join(broken_apps)}"
136
+ else:
137
+ return True, f"{len(packages)} uygulama yüklü (tümü geçerli)"
138
+
139
+ except Exception as e:
140
+ return False, f"Uygulama listesi kontrol edilemedi: {str(e)}"
141
+
142
+ def check_python_modules():
143
+ """Gerekli Python modüllerini kontrol eder"""
144
+ required_modules = [
145
+ ("json", "JSON desteği"),
146
+ ("os", "İşletim sistemi arayüzü"),
147
+ ("sys", "Sistem arayüzü"),
148
+ ("pathlib", "Dosya yolu işlemleri"),
149
+ ("subprocess", "Alt süreç yönetimi"),
150
+ ("argparse", "Komut satırı ayrıştırma"),
151
+ ]
152
+
153
+ missing = []
154
+ found = []
155
+
156
+ for module_name, description in required_modules:
157
+ try:
158
+ __import__(module_name)
159
+ found.append(module_name)
160
+ except ImportError:
161
+ missing.append(f"{module_name} ({description})")
162
+
163
+ if missing:
164
+ return False, f"Eksik Python modülleri: {', '.join(missing)}"
165
+ else:
166
+ return True, f"Tüm gerekli modüller mevcut ({len(found)} modül)"
167
+
168
+ def run_doctor():
169
+ """Kapsamlı sistem tanılaması yapar"""
170
+ print("🩺 clapp Sistem Tanılaması")
171
+ print("=" * 60)
172
+ print("Sisteminiz clapp için uygun mu kontrol ediliyor...")
173
+ print()
174
+
175
+ # Tüm kontroller
176
+ checks = [
177
+ ("Python Sürümü", check_python_version),
178
+ ("Platform Bilgisi", check_platform_info),
179
+ ("Python Çalıştırılabilir", check_python_executable),
180
+ ("Çalışma Dizini", check_working_directory),
181
+ ("clapp PATH Kontrolü", check_clapp_in_path),
182
+ ("PATH Ortam Değişkeni", check_path_environment),
183
+ ("Sistem Bağımlılıkları", check_dependencies),
184
+ ("Python Modülleri", check_python_modules),
185
+ ("apps/ Dizini", check_apps_directory),
186
+ ("Yüklü Uygulamalar", check_installed_apps),
187
+ ("Yazma İzinleri", check_permissions),
188
+ ("Disk Alanı", check_disk_space),
189
+ ("Ağ Erişimi", check_network_access),
190
+ ("Flet Kurulumu", check_flet_installation),
191
+ ("clapp Konfigürasyonu", check_clapp_config),
192
+ ]
193
+
194
+ passed = 0
195
+ failed = 0
196
+ warnings = 0
197
+
198
+ results = []
199
+
200
+ for check_name, check_func in checks:
201
+ try:
202
+ success, message = check_func()
203
+ results.append((check_name, success, message))
204
+
205
+ if success:
206
+ print(f"✅ {check_name}: {message}")
207
+ passed += 1
208
+ else:
209
+ print(f"❌ {check_name}: {message}")
210
+ failed += 1
211
+ except Exception as e:
212
+ error_msg = f"Hata - {str(e)}"
213
+ results.append((check_name, False, error_msg))
214
+ print(f"⚠️ {check_name}: {error_msg}")
215
+ warnings += 1
216
+
217
+ # Özet
218
+ print("\n" + "=" * 60)
219
+ print("📊 Tanılama Özeti:")
220
+ print(f"✅ Başarılı: {passed}")
221
+ print(f"❌ Başarısız: {failed}")
222
+ print(f"⚠️ Uyarı: {warnings}")
223
+
224
+ # Genel durum
225
+ if failed == 0 and warnings == 0:
226
+ print("\n🎉 Mükemmel! Sisteminiz clapp için tamamen hazır.")
227
+ print("✨ Herhangi bir sorun bulunmadı.")
228
+ elif failed == 0:
229
+ print("\n✅ İyi! Sisteminiz clapp için genel olarak uygun.")
230
+ print("⚠️ Bazı küçük uyarılar var, ancak çalışmaya engel değil.")
231
+ else:
232
+ print("\n🔧 Dikkat! Bazı sorunlar bulundu.")
233
+ print("❌ Aşağıdaki sorunları çözmeniz önerilir:")
234
+
235
+ # Detaylı öneriler
236
+ if failed > 0:
237
+ print("\n💡 Çözüm Önerileri:")
238
+
239
+ for check_name, success, message in results:
240
+ if not success:
241
+ print(f"\n🔧 {check_name}:")
242
+ print(f" Sorun: {message}")
243
+
244
+ # Spesifik öneriler
245
+ if "Python" in check_name and "sürüm" in message.lower():
246
+ print(" Çözüm: Python 3.8 veya daha yeni sürüm yükleyin")
247
+ elif "PATH" in check_name:
248
+ print(" Çözüm: Python Scripts dizinini PATH'e ekleyin")
249
+ print(" Detay: clapp check-env komutunu çalıştırın")
250
+ elif "apps/" in check_name:
251
+ print(" Çözüm: mkdir apps komutu ile apps dizini oluşturun")
252
+ elif "Flet" in check_name:
253
+ print(" Çözüm: pip install flet komutu ile Flet'i yükleyin")
254
+ elif "izin" in message.lower():
255
+ print(" Çözüm: Dizin izinlerini kontrol edin veya farklı dizinde çalıştırın")
256
+ elif "disk" in message.lower():
257
+ print(" Çözüm: Disk alanı açın veya farklı dizinde çalıştırın")
258
+ elif "ağ" in message.lower():
259
+ print(" Çözüm: İnternet bağlantınızı kontrol edin")
260
+
261
+ # Sonraki adımlar
262
+ print("\n🚀 Sonraki Adımlar:")
263
+ if failed == 0:
264
+ print("• clapp list - Yüklü uygulamaları listeleyin")
265
+ print("• clapp gui - Grafik arayüzü başlatın")
266
+ print("• clapp --help - Tüm komutları görün")
267
+ else:
268
+ print("• Yukarıdaki sorunları çözün")
269
+ print("• clapp doctor - Tekrar tanılama çalıştırın")
270
+ print("• clapp check-env - Temel kontrolleri yapın")
271
+
272
+ print("\n📞 Yardım:")
273
+ print("• GitHub: https://github.com/user/clapp")
274
+ print("• Dokümantasyon: README.md dosyasını okuyun")
275
+
276
+ return failed == 0
277
+
278
+ if __name__ == "__main__":
279
+ run_doctor()