The parted.Device object now provides a getSize() method to return the size of the device in a human-readable format. --- iw/autopart_type.py | 2 +- iw/bootloader_main_gui.py | 2 +- iw/partition_gui.py | 2 +- iw/partition_ui_helpers_gui.py | 2 +- partedUtils.py | 5 ----- textw/partition_text.py | 2 +- 6 files changed, 5 insertions(+), 10 deletions(-) diff --git a/iw/autopart_type.py b/iw/autopart_type.py index f166eab..9c7a1e1 100644 --- a/iw/autopart_type.py +++ b/iw/autopart_type.py @@ -379,7 +379,7 @@ class PartitionTypeWindow(InstallWindow): for disk in self.diskset.disks.values(): if not disk.dev.path[5:] in self.anaconda.id.bootloader.drivelist: continue - size = partedUtils.getDeviceSizeMB(disk.dev) + size = disk.dev.getSize(unit="MB") dispstr = "%s %8.0f MB %s" %(disk.dev.path[5:], size, disk.dev.model) i = bootstore.append(None) bootstore[i] = (dispstr, disk.dev.path[5:]) diff --git a/iw/bootloader_main_gui.py b/iw/bootloader_main_gui.py index 11cb760..615d056 100644 --- a/iw/bootloader_main_gui.py +++ b/iw/bootloader_main_gui.py @@ -97,7 +97,7 @@ class MainBootloaderWindow(InstallWindow): keys.sort() for d in keys: - size = partedUtils.getDeviceSizeMB(disks[d].dev) + size = disks[d].dev.getSize(unit="MB") m = disks[d].dev.model i = model.append(None) diff --git a/iw/partition_gui.py b/iw/partition_gui.py index b2c11fd..5bf359e 100644 --- a/iw/partition_gui.py +++ b/iw/partition_gui.py @@ -326,7 +326,7 @@ class DiskStripeGraph: else: drivetext = _("Drive %s (%-0.f MB) " "(Model: %s)") % ('/dev/' + drive, - partedUtils.getDeviceSizeMB(disk.dev), + disk.dev.getSize(unit="MB"), disk.dev.model) diff --git a/iw/partition_ui_helpers_gui.py b/iw/partition_ui_helpers_gui.py index a08da72..c2c491b 100644 --- a/iw/partition_ui_helpers_gui.py +++ b/iw/partition_ui_helpers_gui.py @@ -137,7 +137,7 @@ def createAllowedDrivesStore(disks, reqdrives, drivelist, selectDrives=True, drives = disks.keys() drives.sort() for drive in drives: - size = getDeviceSizeMB(disks[drive].dev) + size = disks[drive].dev.getSize(unit="MB") selected = 0 if selectDrives: diff --git a/partedUtils.py b/partedUtils.py index 1096e5f..ad14a78 100644 --- a/partedUtils.py +++ b/partedUtils.py @@ -75,11 +75,6 @@ def getPartSizeMB(partition): return (partition.geom.length * partition.geom.dev.sector_size / 1024.0 / 1024.0) -def getDeviceSizeMB(dev): - """Return the size of dev in megabytes.""" - return (float(dev.heads * dev.cylinders * dev.sectors) / (1024 * 1024) - * dev.sector_size) - def getMaxAvailPartSizeMB(part): """Return the maximum size this partition can grow to by looking at contiguous freespace partitions.""" diff --git a/textw/partition_text.py b/textw/partition_text.py index 1944ee1..9598168 100644 --- a/textw/partition_text.py +++ b/textw/partition_text.py @@ -1551,7 +1551,7 @@ class PartitionTypeWindow: cleardrives = anaconda.id.partitions.autoClearPartDrives for disk in disks: - size = getDeviceSizeMB(anaconda.id.diskset.disks[disk].dev) + size = anaconda.id.diskset.disks[disk].dev.getSize(unit="MB") model = anaconda.id.diskset.disks[disk].dev.model if not cleardrives or len(cleardrives) < 1: -- 1.6.1.3 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list