Pure-python S.M.A.R.T library.
Project description
SMARTie
Note: This library is in beta. Please, create a ticket if you run into an issue.
This is a pure-python library for getting basic disk information such as model, serial number, disk health, temperature, etc...
It provides a high-level abstraction to enumerate devices and retrieve basic details:
from smartie.device import get_all_devices
for device in get_all_devices():
print(device.path)
print(device.model_number)
print(device.temperature)
... as well as a lower-level interface for sending SCSI messages:
from smartie import structures, constants
from smartie.device import Device
device = Device('\\.\PhysicalDrive0') # or /dev/sda on Linux
with device.io as dio:
# Send an SCSI INQUIRY command, and get back both the result data and the
# sense response.
result, sense = dio.inquiry()
# ... or send a raw INQUIRY yourself:
inquiry = structures.InquiryResponse()
inquiry_command = structures.InquiryCommand(
operation_code=constants.OperationCode.INQUIRY,
allocation_length=96
)
sense = dio.issue_command(
constants.Direction.FROM,
inquiry_command,
inquiry
)
Support
OS | SCSI/ATA Supported | NVME Supported | Notes |
---|---|---|---|
Linux | Yes | In-progress | SG_IO v3 (Linux 2.6+) |
Windows | Yes | In-progress | |
OS X | In-progress* | N/A | *IDENTITY and SMART-related commands only. |
OS X explicitly denies access to SCSI/ATA pass-through, except for IDENTITY and some SMART-related commands, so this is all we can support. Work for OS X is currently in-progress.
Installation
SMARTie requires Python 3.8 or greater (due to the use of @cached_property
).
pip install smartie
Why?
This library is extracted from PortableHardwareMonitor monitor, where I don't want to force users to install something like smartmontools just to support showing disk temperature!
This library ended up being great for poking, prodding, testing and debugging SCSI/ATA with quick iteration, so hopefully it'll be useful to others.
Contributing
Compatibility contributions are welcome and greatly encouraged, especially considering the sheer number of variations of devices out there.
Changes that severely impact readability in exchange for a bit of performance may be rejected or rewritten. I'm hopeful this library will develop as a learning resource, and readability is a priority.
FAQ
This library isn't returning any of my drives?
The APIs this library uses to communicate with devices typically require root (on Linux) or administrator (on Windows) access to work.
My drive doesn't work with this library?
Support for drives that don't follow modern standards is still a work in progress. Open an issue.
Library Y does X, can I copy that code?
It depends. This library is available under the MIT license and is a fun side project. I want anyone to be able to use it. Many existing projects are GPL or LGPL, so you need to avoid them when contributing to this project. Instead:
- Use the specifications or vendor documentation whenever possible.
- Use the SG_IO documentation by Danny (https://sg.danny.cz/sg/).
- Use the conversations in mailing lists and bug trackers, while avoiding the code.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file smartie-1.0.3.tar.gz
.
File metadata
- Download URL: smartie-1.0.3.tar.gz
- Upload date:
- Size: 17.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa0ef85f6b95d1a876f6ef5c16b7615af1ae7a806847a97cb1411dceb0fb377c |
|
MD5 | 08a482a9ebb93dec478d6cf54d642c7d |
|
BLAKE2b-256 | 7560d561d64588065522a511b04b893bad6d37d49cf5f12fd577d21dbebfba09 |
File details
Details for the file smartie-1.0.3-py3-none-any.whl
.
File metadata
- Download URL: smartie-1.0.3-py3-none-any.whl
- Upload date:
- Size: 18.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba03a42236aaf32e22ce3e17439a2fffe8327190f91c71969d6457427e27e836 |
|
MD5 | 6326ff7353bb7f76baeaee05ea50e802 |
|
BLAKE2b-256 | ba192916e0272415cbb1c8aae63ad5c2fec0ae8c95a7908580fc95c08fcb1c52 |