From ea3de89e4be517e1ebd95e27b5365e5d67894532 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Thu, 31 Oct 2019 11:46:55 +0100 Subject: [PATCH] check_for_fat(): use subprocess.check_output to avoid dependency on Python 3.7 The text=... option for subprocess.Popen was added in Python 3.7 only ("text was added as a more readable alias for universal_newlines"), and also "encoding" and "errors" were introduced in Python 3.6 only. We don't want to stick to a specific py3k version, so let's try to be as backwards compatible as possible. Since we only need stdout of blkid let's switch to subprocess.check_output instead. Thanks: Florian Apolloner for review and feedback --- grml2usb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/grml2usb b/grml2usb index b12cf88..7434901 100755 --- a/grml2usb +++ b/grml2usb @@ -804,9 +804,7 @@ def check_for_fat(partition): " (wrong UID/permissions or device/directory not present?)" % partition) try: - udev_info = subprocess.Popen(["/sbin/blkid", "-s", "TYPE", "-o", "value", partition], - stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - filesystem = udev_info.communicate()[0].rstrip() + filesystem = subprocess.check_output(["/sbin/blkid", "-s", "TYPE", "-o", "value", partition]).decode().rstrip() if filesystem != "vfat": raise CriticalException( @@ -814,7 +812,7 @@ def check_for_fat(partition): "(Use --fat16 or run mkfs.vfat %s)" % (partition, partition)) except OSError: - raise CriticalException("Sorry, /sbin/blkid not available (install e2fsprogs?)") + raise CriticalException("Sorry, /sbin/blkid not available (install util-linux?)") def mkdir(directory): -- 2.1.4