Skip to content
This repository was archived by the owner on Oct 19, 2023. It is now read-only.

Commit 36b596e

Browse files
FlekerGerrit Code Review
authored and
Gerrit Code Review
committed
Merge "Checks that list response contains values"
2 parents 7c42271 + 3609f86 commit 36b596e

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

google-assistant-sdk/googlesamples/assistant/grpc/devicetool.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -411,11 +411,17 @@ def list(ctx, resource):
411411
response = json.loads(r.text)
412412
logging.debug(r.text)
413413
if resource == 'deviceModels':
414-
for devicemodel in response['deviceModels']:
415-
pretty_print_model(devicemodel)
414+
if 'deviceModels' in response:
415+
for devicemodel in response['deviceModels']:
416+
pretty_print_model(devicemodel)
417+
else:
418+
logging.info('No device models found')
416419
elif resource == 'devices':
417-
for device in response['devices']:
418-
pretty_print_device(device)
420+
if 'devices' in response:
421+
for device in response['devices']:
422+
pretty_print_device(device)
423+
else:
424+
logging.info('No devices found')
419425

420426

421427
def main():

0 commit comments

Comments
 (0)