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

Method _parse_nmcli_scan

wardriving.py:3021–3059  ·  view source on GitHub ↗

Parse nmcli terse WiFi scan output.

(self, output)

Source from the content-addressed store, hash-verified

3019 # so the status bar matches what Huginn actually sees, not stream volume)
3020 try:
3021 row = conn.execute(
3022 "SELECT COUNT(*) FROM bluetooth_devices "
3023 "WHERE device_type IN ('BLE','Flipper','AirTag','Skimmer')"
3024 ).fetchone()
3025 result['esp_ble_count'] = row[0] if row else 0
3026 except Exception:
3027 pass
3028 # Unique Zigbee / 802.15.4 devices seen via a companion radio.
3029 # DB-backed so the status bar reflects unique devices, not
3030 # the running stream line count.
3031 try:
3032 row = conn.execute(
3033 "SELECT COUNT(*) FROM zigbee_devices"
3034 ).fetchone()
3035 result['esp_zigbee_count'] = row[0] if row else 0
3036 result['zigbee_count'] = result['esp_zigbee_count']
3037 except Exception:
3038 pass
3039 except Exception:
3040 result['serial_unique'] = 0
3041 result['serial_seen_unique'] = 0
3042 return result
3043
3044 def get_session_list(self):
3045 """List all saved wardriving sessions."""
3046 wd_dir = os.path.join(self.data_dir, 'wardriving')
3047 if not os.path.isdir(wd_dir):
3048 return []
3049 sessions = []
3050 for f in sorted(os.listdir(wd_dir), reverse=True):
3051 if f.startswith('session_') and f.endswith('.db'):
3052 sid = f[8:-3] # strip 'session_' and '.db'
3053 db_path = os.path.join(wd_dir, f)
3054 size = os.path.getsize(db_path)
3055 try:
3056 with sqlite3.connect(db_path) as conn:
3057 conn.row_factory = sqlite3.Row
3058 total = conn.execute("SELECT COUNT(*) FROM networks").fetchone()[0]
3059 info = {}
3060 for row in conn.execute("SELECT key, value FROM session_info").fetchall():
3061 info[row[0]] = row[1]
3062 sessions.append({

Callers 1

_scan_interfaceMethod · 0.95

Calls 2

_freq_to_channelFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected