Fix dry-mode API failures and fast SIGTERM shutdown
This commit is contained in:
@@ -173,18 +173,21 @@ class NetworkManager:
|
||||
return sorted_items
|
||||
|
||||
def _scan_with_wpa_cli(self) -> List[str]:
|
||||
cmd_scan = ["wpa_cli", "-i", self.interface, "scan"]
|
||||
proc = self._run(cmd_scan, timeout=15)
|
||||
if proc.returncode != 0 or "OK" not in proc.stdout:
|
||||
return []
|
||||
try:
|
||||
cmd_scan = ["wpa_cli", "-i", self.interface, "scan"]
|
||||
proc = self._run(cmd_scan, timeout=15)
|
||||
if proc.returncode != 0 or "OK" not in proc.stdout:
|
||||
return []
|
||||
|
||||
for _ in range(8):
|
||||
time.sleep(1)
|
||||
proc_results = self._run(["wpa_cli", "-i", self.interface, "scan_results"], timeout=10)
|
||||
if proc_results.returncode == 0 and len(proc_results.stdout.splitlines()) > 1:
|
||||
parsed = self._parse_scan_results(proc_results.stdout)
|
||||
if parsed:
|
||||
return [ssid for ssid, _signal in parsed]
|
||||
for _ in range(8):
|
||||
time.sleep(1)
|
||||
proc_results = self._run(["wpa_cli", "-i", self.interface, "scan_results"], timeout=10)
|
||||
if proc_results.returncode == 0 and len(proc_results.stdout.splitlines()) > 1:
|
||||
parsed = self._parse_scan_results(proc_results.stdout)
|
||||
if parsed:
|
||||
return [ssid for ssid, _signal in parsed]
|
||||
except Exception:
|
||||
return []
|
||||
return []
|
||||
|
||||
def _scan_with_iw(self) -> List[str]:
|
||||
@@ -208,9 +211,12 @@ class NetworkManager:
|
||||
return ssids
|
||||
|
||||
def scan_networks(self) -> List[str]:
|
||||
ssids = self._scan_with_wpa_cli()
|
||||
if not ssids:
|
||||
ssids = self._scan_with_iw()
|
||||
try:
|
||||
ssids = self._scan_with_wpa_cli()
|
||||
if not ssids:
|
||||
ssids = self._scan_with_iw()
|
||||
except Exception:
|
||||
ssids = []
|
||||
|
||||
if ssids:
|
||||
self.state.set_known_ssids(ssids)
|
||||
|
||||
Reference in New Issue
Block a user