From 90bb37d69b146d83ae73b3853ff047a6f4fdfa84 Mon Sep 17 00:00:00 2001 From: woodtechie1428 <82487883+woodtechie1428@users.noreply.github.com> Date: Tue, 14 Sep 2021 23:49:54 -0400 Subject: [PATCH] Updated sample to use python dict get() method to avoid KeyNotFound exception Is this a breaking change? - No Are all new or changed code paths covered by unit testing? - n/a A complete listing of issues addressed or closed with this change. - updated to use python dict `get()` method to return None instead of a KeyNotFound exception A complete listing of any enhancements provided by this change. - n/a Any usage details developers may need to make use of this new functionality. - no Does additional documentation need to be developed beyond what is listed in your Pull Request? - no Any other salient points of interest. --- samples/hosts/sensor_versions_by_hostname.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/hosts/sensor_versions_by_hostname.py b/samples/hosts/sensor_versions_by_hostname.py index 8eeedcd5..79cfea28 100644 --- a/samples/hosts/sensor_versions_by_hostname.py +++ b/samples/hosts/sensor_versions_by_hostname.py @@ -26,8 +26,8 @@ def device_detail(aids: list): # return just the aid and agent version for device in result["body"]["resources"]: res = {} - res["hostname"] = device["hostname"] - res["agent_version"] = device["agent_version"] + res["hostname"] = device.get("hostname", None) + res["agent_version"] = device.get("agent_version", None) devices.append(res) return devices