diff --git a/lld-disks.py b/lld-disks.py index 48fd3d6..a42081b 100644 --- a/lld-disks.py +++ b/lld-disks.py @@ -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))