Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tuple does not have get #10

Merged
merged 2 commits into from
Nov 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions googledevices/api/bluetooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,30 +94,31 @@ async def scan_for_devices_multi_run(self, runs=2):
await self.get_scan_result()
if master is None:
for device in self._devices:
mac = device['mac_address']
mac = device.get('mac_address')
master[mac] = {}
master[mac]['rssi'] = device['rssi']
master[mac]['device_class'] = device['device_class']
master[mac]['name'] = device['name']
master[mac]['device_type'] = device['device_type']
master[mac]['rssi'] = device.get('rssi')
master[mac]['device_class'] = device.get('device_class')
master[mac]['name'] = device.get('name')
master[mac]['device_type'] = device.get('device_type')
master[mac]['count'] = 1
else:
for device in self._devices:
mac = device['mac_address']
mac = device.get('mac_address')
if master.get(mac, False):
master[mac]['rssi'] = device['rssi']
master[mac]['rssi'] = device.get('rssi')
master[mac]['count'] = str(1 + 1)
else:
master[mac] = {}
master[mac]['rssi'] = device['rssi']
master[mac]['device_class'] = device['device_class']
master[mac]['name'] = device['name']
master[mac]['device_type'] = device['device_type']
master[mac]['rssi'] = device.get('rssi')
device_class = device.get('device_class')
master[mac]['device_class'] = device_class
master[mac]['name'] = device.get('name')
master[mac]['device_type'] = device.get('device_type')
master[mac]['count'] = 1
run = run + 1
result = []
for device in master:
if int(master[device]['count']) > 1:
if int(master.get(device, {}).get('count')) > 1:
result.append(master[device])
self._devices = result

Expand Down
4 changes: 2 additions & 2 deletions googledevices/cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ async def get_all_units():
all_devices = []
if network is None:
import netifaces
gateway = netifaces.gateways()
subnet = gateway['default'][netifaces.AF_INET][0][:-1] + '0/24'
gateway = netifaces.gateways().get('default', {})
subnet = gateway.get(netifaces.AF_INET, ())[0][:-1] + '0/24'
else:
subnet = network
async with aiohttp.ClientSession() as session:
Expand Down