def enum(cls, filt=[]): for drv in cls._drivers: drv_path = sysfs_path('/sys/bus/pci/drivers', drv.PCI_DRIVER) if os.path.exists(drv_path): return drv.enum(filt) print('no fpga drivers loaded')
def __init__(self, _sysfs_path): """__init__ Initializes a new sysfs_node object with a sysfs path. Args: sysfs_path: sysfs path to a 'file' or 'directory' object. """ super(sysfs_node, self).__init__() self._sysfs_path = sysfs_path(_sysfs_path)
def enum_devices(cls): """enum_devices Discover sysfs devices under a given device root. """ nodes = [] paths = glob.glob(sysfs_path(cls.DEVICE_ROOT, '*')) # log.debug('found %s objects: %s', sysfs_class_name, class_paths) for path in paths: nodes.append(cls(path)) return nodes
def enum_class(cls, sysfs_class_name, sysfs_class=None): """enum_class Discover class_node objects under a given "class". Args: sysfs_class_name: The name of the class under /sys/class to look at. sysfs_class(class_node): The class_node or deriving class to use when creating class_node objects. Notes: If 'sysfs_class' is not specified, it will use this class. This is meant so that classes deriving from this can omit this. """ sysfs_class = sysfs_class or cls log = LOG(cls.__name__) nodes = [] class_paths = glob.glob(sysfs_path('class', sysfs_class_name, '*')) log.debug('found %s objects: %s', sysfs_class_name, class_paths) for path in class_paths: nodes.append(sysfs_class(path)) return nodes