diff --git a/tangostationcontrol/tangostationcontrol/clients/snmp_client.py b/tangostationcontrol/tangostationcontrol/clients/snmp_client.py index 01286464536846b08f2fea4754e7010ee6e2f333..f3318827af3c3d526e4367053388a6cdcfb2b8d6 100644 --- a/tangostationcontrol/tangostationcontrol/clients/snmp_client.py +++ b/tangostationcontrol/tangostationcontrol/clients/snmp_client.py @@ -54,18 +54,16 @@ class SNMP_client(CommClient): def _process_annotation(self, annotation): - # check if the 'mib' and 'name' keys are present - if 'mib' in annotation and 'name' in annotation: + try: mib = annotation["mib"] name = annotation["name"] # SNMP has tables that require an index number to access them. regular non-table variable have an index of 0 idx = annotation.get('index', 0) - else: - raise ValueError(f"SNMP attribute annotation requires a dict argument with both a 'name' and 'mib' key. Instead got: {annotation}") - - return mib, name, idx + return mib, name, idx + except KeyError: + raise ValueError(f"SNMP attribute annotation requires a dict argument with both a 'name' and 'mib' key. Instead got: {annotation}") def setup_value_conversion(self, attribute): """