Skip to content

Device

linuxpy.device

ReentrantOpen()

Bases: AbstractContextManager

Base for a reusable, reentrant (but not thread safe) open/close context manager

open()

Mandatory override for concrete sub-class

close()

Mandatory override for concrete sub-class

BaseDevice(name_or_file, read_write=True, io=IO)

Bases: ReentrantOpen

Base class for a reentrant device

closed: bool property

True if the stream is closed. Always succeeds

is_blocking: bool property

True if the underlying OS is opened in blocking mode. Raises error if device is not opened.

from_id(did: int, **kwargs) classmethod

Create a new Device from the given id

open()

Open the device if not already open. Triggers _on_open after the underlying OS open has succeeded

close()

Closes the device if not already closed. Triggers _on_close before the underlying OS open has succeeded

fileno() -> int

Return the underlying file descriptor (an integer) of the stream if it exists

device_number(path: PathLike) -> Optional[int]

Retrieves device number from a path like. Example: gives 12 for /dev/video12

is_device_file(path: PathLike, read_write: bool = True)

Check if path like is a readable (and, optionally, writable) character device.

iter_device_files(path: PathLike = '/dev', pattern: str = '*') -> Iterable[pathlib.Path]

Iterable of accessible (read & write) char device files under the given path