Fix error message for unintialized partition [Closes: 857]
[grml2usb.git] / grml2usb
index 3982380..e85d574 100755 (executable)
--- 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?)")