()
| 14283 | # Read and analyze wifi network data |
| 14284 | network_data = read_wifi_network_data() |
| 14285 | debug_info['data_sources']['wifi_network_data'] = { |
| 14286 | 'total_entries': len(network_data), |
| 14287 | 'alive_entries': len([entry for entry in network_data if entry.get('Alive') in [True, 'True', '1', 1]]), |
| 14288 | 'sample_entries': network_data[:3] if network_data else [], |
| 14289 | 'all_alive_values': list(set([str(entry.get('Alive', 'MISSING')) for entry in network_data])), |
| 14290 | 'ip_list': [entry.get('IPs', 'NO_IP') for entry in network_data[:10]] |
| 14291 | } |
| 14292 | |
| 14293 | except Exception as e: |
| 14294 | debug_info['errors_and_warnings'].append(f"Error reading WiFi network data: {str(e)}") |
| 14295 | |
| 14296 | try: |
| 14297 | # NetKB data |
| 14298 | netkb_data = shared_data.read_data() |
| 14299 | netkb_file_path = getattr(shared_data, 'netkbfile', 'NOT_SET') |
| 14300 | debug_info['data_sources']['netkb_data'] = { |
| 14301 | 'total_entries': len(netkb_data), |
| 14302 | 'alive_entries': len([entry for entry in netkb_data if entry.get('Alive') in ['1', 1]]), |
| 14303 | 'sample_entries': netkb_data[:3] if netkb_data else [], |
| 14304 | 'all_alive_values': list(set([str(entry.get('Alive', 'MISSING')) for entry in netkb_data])), |
| 14305 | 'file_path': netkb_file_path, |
| 14306 | 'file_exists': os.path.exists(netkb_file_path) if netkb_file_path != 'NOT_SET' else False |
| 14307 | } |
| 14308 | except Exception as e: |
| 14309 | debug_info['errors_and_warnings'].append(f"Error reading NetKB data: {str(e)}") |
| 14310 | |
| 14311 | # === CACHE STATE DEBUGGING === |
| 14312 | debug_info['cache_state'] = { |
| 14313 | 'network_scan_cache_keys': list(network_scan_cache.keys()), |
| 14314 | 'arp_hosts_count': len(network_scan_cache.get('arp_hosts', {})), |
| 14315 | 'arp_hosts_sample': dict(list(network_scan_cache.get('arp_hosts', {}).items())[:5]), |
| 14316 | 'last_arp_scan_time': network_scan_cache.get('last_arp_scan', 'NEVER'), |
| 14317 | 'cache_size': len(str(network_scan_cache)), |
| 14318 | 'network_scan_last_update': network_scan_last_update, |
| 14319 | 'arp_scan_interval': ARP_SCAN_INTERVAL, |
| 14320 | 'current_time': time.time(), |
| 14321 | 'time_since_last_cache_update': time.time() - network_scan_last_update if network_scan_last_update else 'NEVER' |
| 14322 | } |
| 14323 | |
| 14324 | # Test ARP scan directly |
| 14325 | try: |
| 14326 | debug_info['api_traces'].append("=== TESTING ARP SCAN DIRECTLY ===") |
| 14327 | test_arp_result = run_arp_scan_localnet(_get_lan_iface()) |
| 14328 | debug_info['cache_state']['direct_arp_test'] = { |
| 14329 | 'success': bool(test_arp_result), |
| 14330 | 'host_count': len(test_arp_result) if test_arp_result else 0, |
| 14331 | 'sample_results': dict(list(test_arp_result.items())[:3]) if test_arp_result else {} |
| 14332 | } |
| 14333 | debug_info['api_traces'].append(f"Direct ARP test found {len(test_arp_result) if test_arp_result else 0} hosts") |
| 14334 | except Exception as e: |
| 14335 | debug_info['errors_and_warnings'].append(f"Error testing ARP scan directly: {str(e)}") |
| 14336 | debug_info['cache_state']['direct_arp_test'] = {'error': str(e)} |
| 14337 | |
| 14338 | # === SYNC INFORMATION === |
| 14339 | debug_info['sync_information'] = { |
| 14340 | 'last_sync_time': getattr(shared_data, 'last_sync_timestamp', 'NOT_SET'), |
| 14341 | 'sync_lock_acquired': sync_lock.locked() if sync_lock else 'NO_LOCK', |
| 14342 | 'sync_background_interval': SYNC_BACKGROUND_INTERVAL, |
nothing calls this directly
no test coverage detected