Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lld-disks.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#!/usr/bin/python
import os
import json
import re

if __name__ == "__main__":
# filter out partitions
rx_sd = re.compile('.*[a-z]$')
# Iterate over all block devices, but ignore them if they are in the
# skippable set
skippable = ("sr", "loop", "ram")
devices = (device for device in os.listdir("/sys/class/block")
if not any(ignore in device for ignore in skippable))
if not any(ignore in device for ignore in skippable)
and rx_sd.match(device))
data = [{"{#DEVICENAME}": device} for device in devices]
print(json.dumps({"data": data}, indent=4))