MCPcopy Create free account
hub / github.com/FastLED/FastLED / main

Function main

ci/debug/validate_port_kill.py:64–126  ·  view source on GitHub ↗

Main validation function.

()

Source from the content-addressed store, hash-verified

62
63
64def main():
65 """Main validation function."""
66 parser = argparse.ArgumentParser(description="Validate port killing functionality")
67 parser.add_argument("port", nargs="?", help="Specific port to check (e.g., COM3)")
68 parser.add_argument(
69 "--kill", action="store_true", help="Kill process using the port"
70 )
71 parser.add_argument("--auto", action="store_true", help="Auto-detect port")
72 args = parser.parse_args()
73
74 print("=" * 60)
75 print("PORT KILL VALIDATION")
76 print("=" * 60)
77 print()
78
79 detected: ComportResult | None = None
80 if args.auto or not args.port:
81 print("Auto-detecting upload port...")
82 detected = auto_detect_upload_port(None)
83 if detected and detected.ok:
84 print(f"✅ Auto-detected: {detected}")
85 print()
86 else:
87 print("❌ No suitable port detected")
88 print()
89
90 if not args.port and not args.auto:
91 # Just list all ports
92 list_all_ports()
93 print("Tip: Run with --auto to auto-detect ESP32/Arduino port")
94 print("Tip: Run with a port name (e.g., COM3) to check that specific port")
95 return
96
97 port_to_check = args.port or (detected.selected_port if detected else None)
98 if not port_to_check:
99 print("No port specified or detected")
100 return
101
102 print(f"Checking port: {port_to_check}")
103 print("-" * 60)
104
105 is_locked = check_port_status(port_to_check)
106 print()
107
108 if is_locked and args.kill:
109 print("Attempting to kill process using port...")
110 print("-" * 60)
111 kill_port_users(port_to_check)
112 print()
113
114 print(f"✅ Port cleanup completed for {port_to_check}")
115 print()
116 print("Re-checking port status...")
117 print("-" * 60)
118 check_port_status(port_to_check)
119 elif is_locked:
120 print("Port is locked. Run with --kill to attempt killing the process.")
121 print(f"Example: uv run python {sys.argv[0]} {port_to_check} --kill")

Callers 1

Calls 6

auto_detect_upload_portFunction · 0.90
kill_port_usersFunction · 0.90
list_all_portsFunction · 0.85
check_port_statusFunction · 0.85
parse_argsMethod · 0.80
printFunction · 0.50

Tested by

no test coverage detected