#NEWLINE# def _validate_device( device ) : #NEWLINE# #INDENT# '\n    Ensure the device name supplied is valid in a manner similar to the\n    `exists` function, but raise errors on invalid input rather than return\n    False.\n\n    This function only validates a block device, it does not check if the block\n    device is a drive or a partition or a filesystem, etc.\n    ' #NEWLINE# if os . path . exists ( dev ) : #NEWLINE# #INDENT# dev = os . stat ( device ) . st_mode #NEWLINE# if stat . S_ISBLK ( dev ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# #UNINDENT# raise CommandExecutionError ( 'Invalid device passed to partition module.' )