Registry / devops / blkinfo

blkinfo

JSON →
library0.2.0pypypi✓ verified 83d ago

blkinfo is a Python package designed to retrieve and list detailed information about all available block devices on a system, or a specified block device. It provides a programmatic interface to access system-level block device data, typically parsing information found in `/sys/class/block`. The current version is 0.2.0, and releases are infrequent, reflecting its stable and specific functionality.

pip install blkinfo
INSTALL
IMPORT
SIG · BLKINFO
B
blkinfo
devopspythonv0.2.0
Install
2.4s avg
Import
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.2MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 2.4s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BlkDiskInfo
from blkinfo import BlkDiskInfo
from blkinfo import BlkInfo

This quickstart demonstrates how to instantiate `BlkInfo` and use its primary methods `get_all_blkdev_info()` to retrieve information for all block devices and `get_blkdev_info()` for a specific device. It includes a check for `/dev/sda` and basic error handling, as permissions are often required.

from blkinfo import BlkInfo # Instantiate BlkInfo blk_info = BlkInfo() # Get information about all available block devices all_block_devices_info = blk_info.get_all_blkdev_info() print("\n--- All Block Devices ---") for dev in all_block_devices_info: print(f" Device: {dev['NAME']}, Size: {dev['SIZE']}, Type: {dev['TYPE']}") # To get information about a specified block device (e.g., '/dev/sda') # Note: Device paths vary by system. Use an existing path on your system. # Permissions might be required (e.g., sudo) for full details. import os if os.path.exists('/dev/sda'): try: specified_block_device_info = blk_info.get_blkdev_info("/dev/sda") print("\n--- Specific Block Device (/dev/sda) ---") for key, value in specified_block_device_info.items(): print(f" {key}: {value}") except Exception as e: print(f"Could not get info for /dev/sda: {e}. (Often due to permissions or device not existing)") else: print("\n--- Specific Block Device (/dev/sda) ---") print(" /dev/sda not found. Skipping specific device example.") print(" Try with an existing path like '/dev/nvme0n1' or '/dev/vda' on your system.")
Debug
Known issues
gotchablkinfo is designed for Linux systems. Running it on other operating systems (e.g., Windows, macOS) will not yield correct results and may raise `FileNotFoundError` as it relies on Linux-specific paths like `/sys/class/block`.
fix
Ensure your application runs in a Linux environment where `/sys/class/block` and device files are available.
affects: All versions
gotchaAccessing detailed block device information often requires root privileges. Running your Python script without `sudo` may result in partial or empty data for certain fields, or `PermissionError` when trying to access specific device paths.
fix
Execute your Python script with root privileges (e.g., `sudo python your_script.py`) or ensure the user has appropriate read permissions on `/dev/` and `/sys/class/block`.
affects: All versions
gotchaThe JSON output schema for `get_all_blkdev_info()` and `get_blkdev_info()` received minor internal adjustments in version 0.2.0. While not a major API break, users who strictly parse the dictionary keys or rely on their exact ordering might need to adjust their code.
fix
Always validate the structure of the returned dictionary against the current version's expected output or handle potentially missing/reordered keys gracefully.
affects: 0.2.0 and later
Upgrade
Version history
0.2.0latest on PyPI · released Oct 6, 2021
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
blkinfo — pip install blkinfo · libregistry