By default Subprocess.open() opens file objects in binary mode, so the
"filesystem" variable is an array of bytes, and comparing it to a
string always yields false. Fix that by explicitly opening the stream
in text mode.
try:
udev_info = subprocess.Popen(["/sbin/blkid", "-s", "TYPE", "-o", "value", partition],
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
filesystem = udev_info.communicate()[0].rstrip()
if filesystem != "vfat":