MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / update_scan_mode

Method update_scan_mode

multi_interface.py:450–488  ·  view source on GitHub ↗
(self, mode: Optional[str] = None, focus_interface: Optional[str] = None)

Source from the content-addressed store, hash-verified

448 )
449
450 def update_scan_mode(self, mode: Optional[str] = None, focus_interface: Optional[str] = None) -> Dict:
451 requested_mode = self.get_scan_mode()
452 if mode is not None:
453 normalized = str(mode).strip().lower()
454 if normalized not in (self.MODE_SINGLE, self.MODE_MULTI):
455 raise ValueError("mode must be 'single' or 'multi'")
456 requested_mode = normalized
457
458 focus_provided = focus_interface is not None
459 sanitized_focus = None
460 if focus_provided:
461 sanitized_focus = self._sanitize_interface_name(focus_interface)
462
463 changed = False
464 if self.shared_data.config.get('wifi_multi_scan_mode') != requested_mode:
465 self.shared_data.config['wifi_multi_scan_mode'] = requested_mode
466 changed = True
467
468 desired_multi_flag = (requested_mode == self.MODE_MULTI)
469 if bool(self.shared_data.config.get('wifi_multi_network_scans_enabled', False)) != desired_multi_flag:
470 self.shared_data.config['wifi_multi_network_scans_enabled'] = desired_multi_flag
471 changed = True
472
473 if focus_provided:
474 self.shared_data.config['wifi_multi_scan_focus_interface'] = sanitized_focus or ''
475 changed = True
476 elif requested_mode == self.MODE_SINGLE and not self.get_focus_interface():
477 auto_focus = self._auto_focus_interface() or ''
478 self.shared_data.config['wifi_multi_scan_focus_interface'] = auto_focus
479 changed = True
480
481 if changed:
482 try:
483 self.shared_data.save_config()
484 except Exception as exc:
485 logger.warning(f"Unable to persist multi-interface scan mode: {exc}")
486
487 self._refresh_focus_flags()
488 return self.get_state_payload()
489
490 # ------------------------------------------------------------------
491 # Helpers

Callers 2

_toggle_scan_interfaceFunction · 0.80
update_wifi_scan_modeFunction · 0.80

Calls 9

get_scan_modeMethod · 0.95
get_focus_interfaceMethod · 0.95
_auto_focus_interfaceMethod · 0.95
_refresh_focus_flagsMethod · 0.95
get_state_payloadMethod · 0.95
save_configMethod · 0.80
warningMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected