smartie.device module¶
High-level abstractions for enumerating devices and getting basic device information.
- class smartie.device.Device(path: Path | str)[source]¶
Bases:
ABC
A Device represents a high-level abstraction over a system block device.
Note
Typically, an end user will never instantiate a Device directly, but instead use the
get_device()
function to get a Device instance for a given path. This function will automatically determine the correct subclass to use based on the platform and device type.- Parameters:
path – The filesystem path to the device (such as /dev/sda).
- fd: int | None¶
- get_filters() List[str] [source]¶
Returns a list of filters that should be used when looking up this device in the device database.
- property model: str | None¶
Returns the model name of the device.
- path: str¶
- property serial: str | None¶
Returns the serial number of the device.
- property smart_table¶
Returns the SMART table for the device, if available.
- property temperature: int | None¶
Returns the temperature of the device in degrees Celsius.
- smartie.device.get_all_devices() Iterable[Device] [source]¶
Yields all the devices detected on the host.
for device in get_all_devices(): with device: print(device.model, device.serial)
- smartie.device.get_device(path: Path | str) Device [source]¶
Returns a Device instance for the given path. This is a convenience function for the Device constructor which tries to automatically determine the correct subclass to use.
with get_device("/dev/sda") as device: print(device.model, device.serial)
- Parameters:
path – The filesystem path to the device (such as /dev/sda).