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

Method setup_ap_logger

wifi_manager.py:418–463  ·  view source on GitHub ↗

Setup dedicated logger for AP mode operations

(self)

Source from the content-addressed store, hash-verified

416 if (self._last_ping_sweep_ssid == ssid and
417 now - self._last_ping_sweep_time < cooldown):
418 remaining = int(cooldown - (now - self._last_ping_sweep_time))
419 self.logger.info(f"Ping sweep for {ssid} suppressed - cooldown {remaining}s remaining")
420 return
421
422 if self._ping_sweep_thread and self._ping_sweep_thread.is_alive():
423 self.logger.info("Ping sweep already running - skipping additional trigger")
424 return
425
426 self.logger.info(f"Scheduling initial ping sweep for SSID '{ssid}'")
427 self._last_ping_sweep_time = now
428 self._last_ping_sweep_ssid = ssid
429 self._ping_sweep_thread = threading.Thread(
430 target=self._run_initial_ping_sweep,
431 args=(ssid,),
432 daemon=True
433 )
434 self._ping_sweep_thread.start()
435
436 def _run_initial_ping_sweep(self, ssid):
437 """Background worker that runs the lightweight NetworkScanner ping sweep."""
438 try:
439 from actions.scanning import NetworkScanner
440 except ImportError as import_error:
441 self.logger.error(f"Unable to import NetworkScanner for ping sweep: {import_error}")
442 return
443
444 try:
445 scanner = NetworkScanner(self.shared_data)
446 summary = scanner.run_initial_ping_sweep(include_arp_scan=True)
447 if summary:
448 total_hosts = summary.get('arp_hosts', 0) + summary.get('ping_hosts', 0)
449 cidrs = ', '.join(summary.get('target_cidrs', []))
450 self.logger.info(
451 f"Initial ping sweep for {ssid} completed - {total_hosts} hosts touched across {cidrs}"
452 )
453 else:
454 self.logger.warning(f"Ping sweep for {ssid} finished without summary data")
455 except Exception as exc:
456 import traceback
457 self.logger.error(f"Ping sweep thread failed: {exc}")
458 self.logger.debug(traceback.format_exc())
459
460 def save_wifi_config(self):
461 """Save Wi-Fi configuration to shared data"""
462 try:
463 self.shared_data.config['wifi_known_networks'] = self.known_networks
464 self.shared_data.config['wifi_ap_ssid'] = self.ap_ssid
465 self.shared_data.config['wifi_ap_password'] = self.ap_password
466 self.shared_data.config['wifi_connection_timeout'] = self.connection_timeout

Callers 1

__init__Method · 0.95

Calls 2

infoMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected