diff --git a/scripts/sfpshow b/scripts/sfpshow index 3ee80ea2c068..d05268f74d88 100755 --- a/scripts/sfpshow +++ b/scripts/sfpshow @@ -6,6 +6,7 @@ which accesses the transceiver directly. """ +import ast import os import re import sys @@ -273,10 +274,15 @@ class SFPShow(object): output += '{}{}: {}\n'.format(indent, QSFP_DATA_MAP[key], sfp_info_dict[key]) else: output += '{}{}:\n'.format(indent, QSFP_DATA_MAP['specification_compliance']) - spefic_compliance_dict = eval(sfp_info_dict['specification_compliance']) - sorted_compliance_key_table = natsorted(spefic_compliance_dict) - for compliance_key in sorted_compliance_key_table: - output += '{}{}: {}\n'.format((indent * 2), compliance_key, spefic_compliance_dict[compliance_key]) + + spec_compliance_dict = {} + try: + spec_compliance_dict = ast.literal_eval(sfp_info_dict['specification_compliance']) + sorted_compliance_key_table = natsorted(spec_compliance_dict) + for compliance_key in sorted_compliance_key_table: + output += '{}{}: {}\n'.format((indent * 2), compliance_key, spec_compliance_dict[compliance_key]) + except ValueError as e: + output += '{}N/A\n'.format((indent * 2)) else: output += '{}{}: {}\n'.format(indent, QSFP_DATA_MAP[key], sfp_info_dict[key])