Connect the host machine to a WiFi network.
(self, ssid: str, password: str)
| 54 | # -- public helpers (shared logic) -- |
| 55 | |
| 56 | def connect(self, ssid: str, password: str) -> bool: |
| 57 | """Connect the host machine to a WiFi network.""" |
| 58 | print(f" Connecting host to WiFi '{ssid}' ({self.platform_name})...") |
| 59 | try: |
| 60 | result = self._run_connect(ssid, password) |
| 61 | if result.returncode != 0: |
| 62 | print( |
| 63 | f" {Fore.RED}Failed to connect: {result.stderr}{Style.RESET_ALL}" |
| 64 | ) |
| 65 | return False |
| 66 | print(" Waiting for WiFi connection to establish...") |
| 67 | time.sleep(5) |
| 68 | print(f" {Fore.GREEN}Connected to '{ssid}'{Style.RESET_ALL}") |
| 69 | return True |
| 70 | except (subprocess.TimeoutExpired, FileNotFoundError, OSError) as e: |
| 71 | print(f" {Fore.RED}WiFi connection error: {e}{Style.RESET_ALL}") |
| 72 | return False |
| 73 | |
| 74 | def restore(self, original_ssid: str | None) -> None: |
| 75 | """Restore the host's original WiFi connection.""" |
no test coverage detected