Skip to content

Commit

Permalink
-- Add support for device icon URL
Browse files Browse the repository at this point in the history
-- Added a guard against devices without the correct structure (from PR google#20)
  • Loading branch information
dclobato committed Dec 19, 2020
1 parent 3a3ab49 commit 5aba765
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions lakeside/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@ def get_devices(username, password):
info = r.json()

for item in info['items']:
if item['device'] is not None:
devices.append({
'address': item['device']['wifi']['lan_ip_addr'],
'code': item['device']['local_code'],
'type': item['device']['product']['product_code'],
'name': item['device']['alias_name'],
'id': item['device']['id'],
})
if item['device'] is not None and item['device']['wifi'] is not None:
entry = dict()
entry['address'] = item['device']['wifi']['lan_ip_addr']
entry['code'] = item['device']['local_code']
entry['type'] = item['device']['product']['product_code']
entry['name'] = item['device']['alias_name']
entry['id'] = item['device']['id']
if item['device']['product']['icon_url'] is not None:
entry['icon_url'] = item['device']['product']['icon_url']
devices.append(entry)

return devices

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

setup(
name='lakeside',
version="0.12",
version="0.13",
author='Matthew Garrett',
author_email='[email protected]',
url='http://github.com/google/python-lakeside',
Expand Down

0 comments on commit 5aba765

Please sign in to comment.