diff --git a/tangostationcontrol/tangostationcontrol/clients/snmp_client.py b/tangostationcontrol/tangostationcontrol/clients/snmp_client.py index 1aa527e91558f8ba21e872b21f16fbd094439551..9055789f555df0e6b2da9526c149e024b645549d 100644 --- a/tangostationcontrol/tangostationcontrol/clients/snmp_client.py +++ b/tangostationcontrol/tangostationcontrol/clients/snmp_client.py @@ -60,18 +60,16 @@ class SNMP_client(CommClient): index (optional) the index if the value thats being read from is a table. """ - # 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): """