sherlock / setup.py
bangunx
πŸš€ Initial commit: Complete modular OSINT tool with Gradio interface
c7daaca
#!/usr/bin/env python3
"""
Setup script for Sherlock OSINT Tool
"""
import subprocess
import sys
from pathlib import Path
def run_command(command: str, description: str) -> bool:
"""Run a command and return success status."""
print(f"πŸ”„ {description}...")
try:
result = subprocess.run(command, shell=True, check=True, capture_output=True, text=True)
print(f"βœ… {description} completed successfully")
return True
except subprocess.CalledProcessError as e:
print(f"❌ {description} failed: {e}")
if e.stdout:
print(f"STDOUT: {e.stdout}")
if e.stderr:
print(f"STDERR: {e.stderr}")
return False
def check_uv_installed() -> bool:
"""Check if UV is installed."""
try:
result = subprocess.run(["uv", "--version"], capture_output=True, text=True)
print(f"βœ… UV is installed: {result.stdout.strip()}")
return True
except FileNotFoundError:
print("❌ UV is not installed")
return False
def install_uv() -> bool:
"""Install UV package manager."""
print("πŸ”„ Installing UV package manager...")
try:
# Try to install UV
install_cmd = "curl -LsSf https://astral.sh/uv/install.sh | sh"
result = subprocess.run(install_cmd, shell=True, check=True)
print("βœ… UV installed successfully")
return True
except subprocess.CalledProcessError:
print("❌ Failed to install UV automatically")
print("Please install UV manually: https://astral.sh/uv/")
return False
def setup_environment() -> bool:
"""Set up the Python environment."""
print("\nπŸš€ Setting up Sherlock OSINT Tool environment...")
# Check if UV is installed
if not check_uv_installed():
if not install_uv():
return False
# Create virtual environment and install dependencies
commands = [
("uv sync", "Installing dependencies with UV"),
("uv run python test_sherlock.py", "Running tests"),
]
success = True
for command, description in commands:
if not run_command(command, description):
success = False
break
return success
def main():
"""Main setup function."""
print("πŸ” Sherlock OSINT Tool Setup")
print("=" * 40)
# Check if we're in the right directory
if not Path("data.json").exists():
print("❌ data.json not found. Please run this script from the sherlock directory.")
sys.exit(1)
# Set up environment
if setup_environment():
print("\nπŸŽ‰ Setup completed successfully!")
print("\nπŸ“‹ Next steps:")
print("1. Copy .env.example to .env and configure if needed")
print("2. Run the web interface: uv run python app.py")
print("3. Or run CLI: uv run python -m sherlock.cli --help")
print("\n🌐 Web interface will be available at: http://localhost:7860")
else:
print("\n❌ Setup failed. Please check the errors above.")
sys.exit(1)
if __name__ == "__main__":
main()