networks: Fix issue when looking up AP details

As reported by Jan Costermans, it is possible that for an access point
scanned by a Wi-Fi device, get_ssid() returns None.  The reported as
follows:

  if access_point.get_ssid().get_data() == ssid:

  AttributeError: 'NoneType' object has no attribute 'get_data'
This commit is contained in:
Sunil Mohan Adapa 2016-03-01 21:54:25 +05:30 committed by James Valleroy
parent b38859b0d3
commit 3b7b7881b1
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -172,7 +172,8 @@ def get_status_from_wifi_access_point(device, ssid):
return status
for access_point in device.get_access_points():
if access_point.get_ssid().get_data() == ssid:
if access_point and access_point.get_ssid() and \
access_point.get_ssid().get_data() == ssid:
status['strength'] = access_point.get_strength()
frequency = access_point.get_frequency()
status['channel'] = _get_wifi_channel_from_frequency(frequency)