Commits

Rodrigo Bistolfi committed 257ae67

media.py: Fix parted api change in Partition.size() also

  • Participants
  • Parent commits 98be70f

Comments (0)

Files changed (1)

File vinstall/backend/media.py

         return '<Partition object: %s>' % self.device_path
 
     def __init__(self, device_path):
-        """Initializes a Media object fro the device path."""
+        """Initializes a Media object from the device path."""
         mntpoint = device_path.split("/")[2]
         mntpoint =  "/mnt/" + mntpoint
         if not os.path.exists(mntpoint):
         return is_mounted(self.device_path)
 
     def size(self, unit="GB"):
-        """Return the partition size in the specified unit.  Defaults to GB"""
-        su = round(self._parted_partition.getSize(unit), 1)
+        """Return the partition size in the specified unit as a string.
+        Defaults to GB
+
+        """
+        try:
+            su = round(self._parted_partition.getSize(unit), 1)
+        except AttributeError:
+            su = round(self._parted_partition.getLength(unit), 1)
         return "%s %s"% (su, unit)
 
     def query_filesystem(self):