Check if process matches debug_attached.py kill patterns. Returns: Tuple of (matches, list of matching patterns)
(
proc_name: str, cmdline: list[str] | None, port_name: str
)
| 45 | |
| 46 | |
| 47 | def check_matches_kill_patterns( |
| 48 | proc_name: str, cmdline: list[str] | None, port_name: str |
| 49 | ) -> tuple[bool, list[str]]: |
| 50 | """Check if process matches debug_attached.py kill patterns. |
| 51 | |
| 52 | Returns: |
| 53 | Tuple of (matches, list of matching patterns) |
| 54 | """ |
| 55 | matches: list[str] = [] |
| 56 | proc_name_lower = proc_name.lower() |
| 57 | |
| 58 | # Check Phase 1: pio.exe processes |
| 59 | if proc_name_lower in ["pio.exe", "pio"]: |
| 60 | matches.append("Phase 1: pio.exe process") |
| 61 | |
| 62 | # Check Phase 2: esptool processes |
| 63 | if cmdline: |
| 64 | cmdline_str = " ".join(cmdline).lower() |
| 65 | if "esptool" in cmdline_str or "esptool.exe" in proc_name_lower: |
| 66 | matches.append("Phase 2: esptool process") |
| 67 | |
| 68 | # Check Phase 3: Python PlatformIO processes |
| 69 | if "python" in proc_name_lower and cmdline: |
| 70 | cmdline_str = " ".join(cmdline) |
| 71 | cmdline_lower = cmdline_str.lower() |
| 72 | |
| 73 | # Would skip due to clud protection? |
| 74 | if "clud" in cmdline_lower: |
| 75 | matches.append("Phase 3: PROTECTED (clud)") |
| 76 | elif "pio" in cmdline_lower: |
| 77 | is_pio_command = any( |
| 78 | keyword in cmdline_lower |
| 79 | for keyword in ["pio.exe", "tool-scons", "platformio"] |
| 80 | ) |
| 81 | if is_pio_command: |
| 82 | is_fastled8 = ( |
| 83 | "fastled8" in cmdline_lower or ".platformio" in cmdline_lower |
| 84 | ) |
| 85 | if is_fastled8: |
| 86 | matches.append("Phase 3: Python PlatformIO process") |
| 87 | else: |
| 88 | matches.append("Phase 3: SKIPPED (not fastled8)") |
| 89 | |
| 90 | # Check kill_process_using_port patterns |
| 91 | serial_exes = [ |
| 92 | "python.exe", |
| 93 | "python3.exe", |
| 94 | "python", |
| 95 | "pio.exe", |
| 96 | "pio", |
| 97 | "esptool.exe", |
| 98 | "esptool.py", |
| 99 | "esptool", |
| 100 | "platformio.exe", |
| 101 | "platformio", |
| 102 | "miniterm.exe", |
| 103 | "miniterm.py", |
| 104 | "miniterm", |
no test coverage detected