Skip to content

Commit 5aba765

Browse files
committed
-- Add support for device icon URL
-- Added a guard against devices without the correct structure (from PR google#20)
1 parent 3a3ab49 commit 5aba765

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

lakeside/__init__.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,16 @@ def get_devices(username, password):
4242
info = r.json()
4343

4444
for item in info['items']:
45-
if item['device'] is not None:
46-
devices.append({
47-
'address': item['device']['wifi']['lan_ip_addr'],
48-
'code': item['device']['local_code'],
49-
'type': item['device']['product']['product_code'],
50-
'name': item['device']['alias_name'],
51-
'id': item['device']['id'],
52-
})
45+
if item['device'] is not None and item['device']['wifi'] is not None:
46+
entry = dict()
47+
entry['address'] = item['device']['wifi']['lan_ip_addr']
48+
entry['code'] = item['device']['local_code']
49+
entry['type'] = item['device']['product']['product_code']
50+
entry['name'] = item['device']['alias_name']
51+
entry['id'] = item['device']['id']
52+
if item['device']['product']['icon_url'] is not None:
53+
entry['icon_url'] = item['device']['product']['icon_url']
54+
devices.append(entry)
5355

5456
return devices
5557

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
setup(
2727
name='lakeside',
28-
version="0.12",
28+
version="0.13",
2929
author='Matthew Garrett',
3030
author_email='mjg59@google.com',
3131
url='http://github.com/google/python-lakeside',

0 commit comments

Comments
 (0)