diff --git a/sfputil/main.py b/sfputil/main.py index fd86d95337..3556eed76f 100644 --- a/sfputil/main.py +++ b/sfputil/main.py @@ -264,10 +264,15 @@ def convert_sfp_info_to_output_string(sfp_info_dict): 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) + + 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, spefic_compliance_dict[compliance_key]) + 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])