-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_install.py
More file actions
151 lines (131 loc) · 5.05 KB
/
test_install.py
File metadata and controls
151 lines (131 loc) · 5.05 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
#!/usr/bin/env python3
"""
LogHawk Installation Verification Script
Verifies that LogHawk dependencies are correctly installed and working.
"""
import sys
import subprocess
import importlib
import os
from pathlib import Path
def check_python_version():
"""Check if Python version is 3.8 or higher."""
version = sys.version_info
if version.major >= 3 and version.minor >= 8:
print(f"✅ Python {version.major}.{version.minor}.{version.micro} - Compatible")
return True
else:
print(f"❌ Python {version.major}.{version.minor}.{version.micro} - Requires Python 3.8+")
return False
def check_dependency(package_name, import_name=None):
"""Check if a Python package is installed and importable."""
if import_name is None:
import_name = package_name
try:
module = importlib.import_module(import_name)
version = getattr(module, '__version__', 'unknown')
print(f"✅ {package_name} ({version}) - Installed")
return True
except ImportError:
print(f"❌ {package_name} - Not installed")
return False
def check_playwright_browsers():
"""Check if Playwright browsers are installed."""
try:
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
try:
browser = p.chromium.launch(headless=True)
browser.close()
print("✅ Playwright Chromium browser - Installed and working")
return True
except Exception as e:
print(f"❌ Playwright Chromium browser - Not installed or broken: {e}")
print(" Run: playwright install chromium")
return False
except ImportError:
print("❌ Playwright - Not available for browser check")
return False
def check_ssl_certificates():
"""Check if SSL certificates exist."""
ssl_dir = Path("ssl")
cert_file = ssl_dir / "loghawk-cert.pem"
key_file = ssl_dir / "loghawk-key.pem"
if cert_file.exists() and key_file.exists():
print("✅ SSL certificates - Found")
return True
else:
print("⚠️ SSL certificates - Not found (will be generated automatically)")
return True # Not critical
def check_log_directories():
"""Check if default log directories exist or can be created."""
log_dirs = ["logs", "browser_logs"]
all_good = True
for dir_name in log_dirs:
log_dir = Path(dir_name)
if log_dir.exists():
print(f"✅ {dir_name}/ directory - Exists")
else:
try:
log_dir.mkdir(exist_ok=True)
print(f"✅ {dir_name}/ directory - Created")
except Exception as e:
print(f"❌ {dir_name}/ directory - Cannot create: {e}")
all_good = False
return all_good
def test_basic_import():
"""Test importing core LogHawk modules."""
try:
# Test if we can import the main LogHawk files
if Path("log_server.py").exists():
print("✅ log_server.py - Found")
else:
print("❌ log_server.py - Missing")
return False
if Path("run_loghawk.py").exists():
print("✅ run_loghawk.py - Found")
else:
print("❌ run_loghawk.py - Missing")
return False
return True
except Exception as e:
print(f"❌ LogHawk core files - Error: {e}")
return False
def main():
"""Run all verification checks."""
print("🦅 LogHawk Installation Verification")
print("=" * 40)
checks = [
("Python Version", check_python_version),
("FastAPI", lambda: check_dependency("fastapi")),
("Uvicorn", lambda: check_dependency("uvicorn")),
("Playwright", lambda: check_dependency("playwright")),
("Playwright Browsers", check_playwright_browsers),
("SSL Certificates", check_ssl_certificates),
("Log Directories", check_log_directories),
("LogHawk Core Files", test_basic_import)
]
passed = 0
total = len(checks)
for check_name, check_func in checks:
print(f"\n🔍 Checking {check_name}...")
if check_func():
passed += 1
print("\n" + "=" * 40)
print(f"📊 Results: {passed}/{total} checks passed")
if passed == total:
print("\n🎉 LogHawk installation is complete and ready!")
print("\n🚀 Next steps:")
print(" 1. python run_loghawk.py")
print(" 2. Open http://127.0.0.1:8765")
print(" 3. For Claude Code: Use loghawk_claude.xml")
return True
else:
print("\n⚠️ Some issues found. Please fix them before running LogHawk.")
if not check_dependency("fastapi") or not check_dependency("uvicorn") or not check_dependency("playwright"):
print("\n📦 To install missing dependencies:")
print(" pip install -r requirements.txt")
return False
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)