Skip to content

Instantly share code, notes, and snippets.

@tasleson
Created March 29, 2018 16:19
Show Gist options
  • Save tasleson/15d88114fd613125b5905d0790a5508c to your computer and use it in GitHub Desktop.
Save tasleson/15d88114fd613125b5905d0790a5508c to your computer and use it in GitHub Desktop.
def is_empty(device_path):
device_info = udev_db.get_device_info(device_path)
# This is probably too simplistic ...
# Check to see if a partition table exists
if 'ID_PART_TABLE_TYPE' in device_info:
return False
# Check if a usage is given, domain includes
# 'filesystem', 'raid', 'other'
if 'ID_FS_USAGE' in device_info:
return False
return True
@dwlehman
Copy link

First conditional should be:

if 'ID_PART_TABLE_TYPE' in device_info and 'ID_PART_ENTRY_DISK' not in device_info:

The rest looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment