Execute iwlist scan and return normalized network list.
(self, interface, *, system_profiles=None, known_ssids=None, log_target=None)
| 235 | return name |
| 236 | except Exception as exc: |
| 237 | self.logger.debug(f"Unable to detect secondary WiFi interface: {exc}") |
| 238 | return None |
| 239 | |
| 240 | @staticmethod |
| 241 | def _parse_nmcli_terse_line(line): |
| 242 | """Parse a single nmcli terse-mode line, handling escaped colons (\\:) in field values.""" |
| 243 | parts = [] |
| 244 | current = '' |
| 245 | i = 0 |
| 246 | while i < len(line): |
| 247 | if line[i] == '\\' and i + 1 < len(line) and line[i + 1] == ':': |
| 248 | current += ':' |
| 249 | i += 2 |
| 250 | elif line[i] == ':': |
| 251 | parts.append(current) |
| 252 | current = '' |
| 253 | i += 1 |
| 254 | else: |
| 255 | current += line[i] |
| 256 | i += 1 |
| 257 | parts.append(current) |
| 258 | return parts |
| 259 | |
| 260 | def _cache_interface_networks(self, interface, networks): |
| 261 | """Cache scan results per interface while preserving legacy attributes.""" |
| 262 | target_iface = self._resolve_scan_interface(interface) |
| 263 | normalized = networks or [] |
| 264 | self.interface_scan_cache[target_iface] = normalized |
| 265 | self.interface_cache_time[target_iface] = time.time() |
| 266 | self.last_scan_interface = target_iface |
| 267 | # Preserve legacy behavior for components that read the flat attribute |
| 268 | self.available_networks = normalized |
| 269 | |
| 270 | def _get_cached_interface_networks(self, interface): |
| 271 | target_iface = self._resolve_scan_interface(interface) |
| 272 | return ( |
| 273 | self.interface_scan_cache.get(target_iface), |
| 274 | self.interface_cache_time.get(target_iface) |
| 275 | ) |
| 276 | |
| 277 | def _get_known_ssids(self): |
| 278 | """Return a deduplicated list of Ragnar-configured SSIDs.""" |
| 279 | known_ssids = [] |
| 280 | seen = set() |
| 281 | try: |
| 282 | for entry in self.known_networks or []: |
| 283 | if isinstance(entry, dict): |
| 284 | ssid = entry.get('ssid') |
| 285 | else: |
| 286 | ssid = str(entry).strip() |
| 287 | if ssid and ssid not in seen: |
| 288 | known_ssids.append(ssid) |
| 289 | seen.add(ssid) |
no test coverage detected