From 601bed9a34fef4dd93bcad3f93cbce080d764e3b Mon Sep 17 00:00:00 2001 From: Swapnil Date: Fri, 5 Jul 2024 18:42:18 +0530 Subject: [PATCH] skip device which doesn't have model number --- agent.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/agent.py b/agent.py index 842b0cc..3647b4f 100644 --- a/agent.py +++ b/agent.py @@ -124,7 +124,12 @@ class ServerData: # Parse the output details = {} - details['model_number'] = re.search(r'Model Number:\s*(.*)', output).group(1) + model_number_match = re.search(r'Model Number:\s*(.*)', output) + if model_number_match is None: + logging.warning("Skipping device {} as it does not have a model number".format(device)) + continue + + details['model_number'] = model_number_match.group(1) details['serial_number'] = re.search(r'Serial Number:\s*(.*)', output).group(1) details['firmware_revision'] = re.search(r'Firmware Revision:\s*(.*)', output).group(1) details['transport'] = re.search(r'Transport:\s*(.*)', output).group(1)