smartie.scsi package

class smartie.scsi.SCSIDevice(path: Path | str)[source]

Bases: Device, ABC

property device_type

Get the device’s type, if available.

get_filters() List[str][source]

Returns a list of filters that should be used when looking up this device in the device database.

identify(try_atapi_on_failure=True) Tuple[IdentifyResponse, SCSIResponse][source]

Issues a standard ATA IDENTIFY command.

Parameters:

try_atapi_on_failure – If True, will try an ATAPI IDENTIFY command if the ATA IDENTIFY command fails.

inquiry() Tuple[InquiryResponse, SCSIResponse][source]

Issues a standard SCSI INQUIRY command.

issue_command(direction: Direction, command: Structure, data: Array | Structure | None, *, timeout: int = 3000) SCSIResponse[source]

Issues an SCSI passthrough command to the disk.

Parameters:
  • direction – Direction for this command.

  • command – Command to be sent to the device.

  • data – Command data to be sent/received to/from the device.

  • timeout – Timeout in milliseconds. Setting this to MAX_INT results in no timeout.

property model: str | None

Returns the model name of the device.

classmethod parse_sense(sense_blob) FixedFormatSense | DescriptorFormatSense | None[source]

Parses the sense response from an SCSI command, raising a smartie.errors.SenseError if an error occurred.

Will return either a structures.FixedFormatSense or a structures.DescriptorFormatSense depending on the error code.

Parameters:

sense_blob – A bytearray (or similar) object containing the unparsed sense response.

property serial: str | None

Returns the serial number of the device.

smart() Tuple[SmartDataResponse, SCSIResponse][source]

Issues an ATA SMART READ_DATA command.

property smart_table: Dict[int, SMARTAttribute]

Returns a parsed and processed dictionary of SMART attributes.

smart_thresholds() Tuple[SmartThresholdResponse, SCSIResponse][source]

Issues an ATA SMART READ_THRESHOLDS command.

property temperature: int | None

Returns the temperature of the device in degrees Celsius.

class smartie.scsi.SCSIResponse(succeeded: bool | None, sense: FixedFormatSense | DescriptorFormatSense | None, command: Command16 | Command12, bytes_transferred: int | None, platform_header: Any)[source]

Bases: object

Common response object for SCSI commands.

This object attempts to encapsulate the response from an SCSI command in a platform-agnostic way. It contains the sense data, the command that was issued, and whether the command succeeded or not.

For additional platform-specific information, the platform_header attribute contains the platform-specific header that was used to issue the command.

bytes_transferred: int | None

The actual number of bytes transferred.

command: Command16 | Command12

The command issued to the device.

platform_header: Any

The platform-specific header that was used to issue the command. For example this may be an SCSIPassThroughDirectWithBuffer on Windows.

sense: FixedFormatSense | DescriptorFormatSense | None

The sense data returned by the device.

succeeded: bool | None

Whether the command succeeded. If None, the status is unknown.

Submodules