MCPcopy Create free account
hub / github.com/GH05TCREW/MetasploitMCP / run_command

Function run_command

run_tests.py:13–31  ·  view source on GitHub ↗

Run a command and handle errors.

(cmd, description="")

Source from the content-addressed store, hash-verified

11from pathlib import Path
12
13def run_command(cmd, description=""):
14 """Run a command and handle errors."""
15 if description:
16 print(f"\n🔄 {description}")
17 print(f"Running: {' '.join(cmd)}")
18
19 try:
20 result = subprocess.run(cmd, check=True, capture_output=True, text=True)
21 print("✅ Success!")
22 if result.stdout:
23 print(result.stdout)
24 return True
25 except subprocess.CalledProcessError as e:
26 print(f"❌ Failed with exit code {e.returncode}")
27 if e.stdout:
28 print("STDOUT:", e.stdout)
29 if e.stderr:
30 print("STDERR:", e.stderr)
31 return False
32
33def check_dependencies():
34 """Check if test dependencies are installed."""

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected