From: Ulrich Dangel Date: Sat, 12 Jun 2010 21:56:57 +0000 (+0200) Subject: Fix error message for unintialized partition [Closes: 857] X-Git-Tag: v0.9.27~3 X-Git-Url: http://git.grml.org/?p=grml2usb.git;a=commitdiff_plain;h=b79a4cc0cfb42be3f9f4aa33993f928bffedd692 Fix error message for unintialized partition [Closes: 857] Do an explicit check if specified partition is at least readable and do not use blkid for it as blkid uses returnvalue 2 for the same reason (no information availabe, wrong permissions). This will give better feedback to the user, e.g. if he forget to format the partition. --- diff --git a/grml2usb b/grml2usb index 3982380..e85d574 100755 --- a/grml2usb +++ b/grml2usb @@ -974,19 +974,19 @@ def check_for_fat(partition): @partition: device name of partition""" + if not os.access(partition, os.R_OK): + raise CriticalException("Failed to read device %s" + " (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) filesystem = udev_info.communicate()[0].rstrip() - if udev_info.returncode == 2: - raise CriticalException("Failed to read device %s" - " (wrong UID/permissions or device/directory not present?)" % partition) - if filesystem != "vfat": raise CriticalException( - "Partition %s does not contain a FAT16 filesystem." % (partition) \ - + "(Use --fat16 or run mkfs.vfat %s)" % (partition)) + "Partition %s does not contain a FAT16 filesystem. " + "(Use --fat16 or run mkfs.vfat %s)" % (partition, partition)) except OSError: raise CriticalException("Sorry, /sbin/blkid not available (install e2fsprogs?)")