in pci_lib/pci_lib.py [0:0]
def aer_rootport_counts(device_name, count_names):
"""Gather PCIe root port device AER error counts, when available."""
rootport_counts = {}
device_name = expand_pci_addr(device_name)
if not device_name:
return None
for count_name in count_names:
filename = os.path.join(SYSFS_PCI_BUS_DEVICES, device_name, count_name)
if not os.path.isfile(filename):
continue
with open(filename) as file_obj:
# For AER root port counts we expect a single line with
# the integer error count that is associated with the
# specific count_name. We'll use the count_name for the
# value's key.
try:
rootport_counts[count_name] = int(file_obj.readline())
except ValueError:
pass
if len(rootport_counts) == 0:
return None
return rootport_counts