FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu Masters Of The Universe

 
 
LinkBack Thread Tools
 
Old 02-11-2009, 11:53 PM
David Cantrell
 
Default Removed partedUtils.getPartSizeMB()

The parted.Partition object provides getSize() to return the size
of the partition in a human-readable format.
---
autopart.py | 9 ++++-----
iw/partition_gui.py | 6 +++---
partRequests.py | 2 +-
partedUtils.py | 7 +------
partitions.py | 6 +++---
textw/partition_text.py | 2 +-
6 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/autopart.py b/autopart.py
index d6fda51..a88fc13 100644
--- a/autopart.py
+++ b/autopart.py
@@ -119,8 +119,7 @@ def bootAlphaCheckRequirements(part):
if free.type & parted.PARTITION_FREESPACE:
break
free = disk.next_partition(free)
- if (not free or free.geom.start != 1L or
- partedUtils.getPartSizeMB(free) < 1):
+ if (not free or free.geom.start != 1L or free.getSize(unit="MB") < 1):
return BOOTALPHA_NO_RESERVED_SPACE

return PARTITION_SUCCESS
@@ -137,7 +136,7 @@ def printNewRequestsCyl(diskset, newRequest):
## partedUtils.end_sector_to_cyl(part.geom.dev, part.geom.end)))

def printFreespaceitem(part):
- return partedUtils.get_partition_name(part), part.geom.start, part.geom.end, partedUtils.getPartSizeMB(part)
+ return partedUtils.get_partition_name(part), part.geom.start, part.geom.end, part.getSize(unit="MB")

def printFreespace(free):
print("Free Space Summary:")
@@ -180,7 +179,7 @@ class partlist:
def __str__(self):
retval = ""
for p in self.parts:
- retval = retval + " %s %s %s
" % (partedUtils.get_partition_name(p), partedUtils.get_partition_file_system_type(p), partedUtils.getPartSizeMB(p))
+ retval = retval + " %s %s %s
" % (partedUtils.get_partition_name(p), partedUtils.get_partition_file_system_type(p), p.getSize(unit="MB"))

return retval

@@ -379,7 +378,7 @@ def fitSized(diskset, requests, primOnly = 0, newParts = None):
continue

lvmLog.debug( "Trying partition %s" % (printFreespaceitem(part),))
- partSize = partedUtils.getPartSizeMB(part)
+ partSize = part.getSize(unit="MB")
# figure out what the request size will be given the
# geometry (#130885)
requestSectors = long((request.requestSize * 1024L * 1024L) / part.disk.dev.sector_size) - 1
diff --git a/iw/partition_gui.py b/iw/partition_gui.py
index 5bf359e..4b43751 100644
--- a/iw/partition_gui.py
+++ b/iw/partition_gui.py
@@ -146,7 +146,7 @@ class DiskStripeSlice:
rc = "Free
"
else:
rc = "%s
" % (get_partition_name(self.partition),)
- rc = rc + "%Ld MB" % (getPartSizeMB(self.partition),)
+ rc = rc + "%Ld MB" % (self.partition.getSize(unit="MB"),)
return rc

def getDeviceName(self):
@@ -835,7 +835,7 @@ class PartitionWindow(InstallWindow):
part = disk.next_partition(part)
continue
# ignore the tiny < 1 MB partitions (#119479)
- if getPartSizeMB(part) <= 1.0:
+ if part.getSize(unit="MB") <= 1.0:
if not part.is_active() or not part.get_flag(parted.PARTITION_BOOT):
part = disk.next_partition(part)
continue
@@ -945,7 +945,7 @@ class PartitionWindow(InstallWindow):
part.geom.start))
self.tree[iter]['End'] = str(end_sector_to_cyl(disk.dev,
part.geom.end))
- size = getPartSizeMB(part)
+ size = part.getSize(unit="MB")
if size < 1.0:
sizestr = "< 1"
else:
diff --git a/partRequests.py b/partRequests.py
index 891afdf..fc108f2 100644
--- a/partRequests.py
+++ b/partRequests.py
@@ -521,7 +521,7 @@ class PartitionSpec(RequestSpec):
if not part:
# XXX kickstart might still call this before allocating the partitions
raise RuntimeError, "Checking the size of a partition which hasn't been allocated yet"
- return partedUtils.getPartSizeMB(part)
+ return part.getSize(unit="MB")

def doSizeSanityCheck(self):
"""Sanity check that the size of the partition is sane."""
diff --git a/partedUtils.py b/partedUtils.py
index ad14a78..cd32c18 100644
--- a/partedUtils.py
+++ b/partedUtils.py
@@ -70,11 +70,6 @@ def getPartSize(partition):
"""Return the size of partition in sectors."""
return partition.geom.length

-def getPartSizeMB(partition):
- """Return the size of partition in megabytes."""
- return (partition.geom.length * partition.geom.dev.sector_size
- / 1024.0 / 1024.0)
-
def getMaxAvailPartSizeMB(part):
"""Return the maximum size this partition can grow to by looking
at contiguous freespace partitions."""
@@ -149,7 +144,7 @@ def get_partition_file_system_type(part):
elif part.fs_type == None:
return None
elif (part.get_flag(parted.PARTITION_BOOT) == 1 and
- getPartSizeMB(part) <= 1 and part.fs_type.name == "hfs"):
+ part.getSize(unit="MB") <= 1 and part.fs_type.name == "hfs"):
ptype = fsset.fileSystemTypeGet("Apple Bootstrap")
elif part.fs_type.name == "linux-swap":
ptype = fsset.fileSystemTypeGet("swap")
diff --git a/partitions.py b/partitions.py
index b98a374..97c3271 100644
--- a/partitions.py
+++ b/partitions.py
@@ -419,7 +419,7 @@ class Partitions:

start = part.geom.start
end = part.geom.end
- size = partedUtils.getPartSizeMB(part)
+ size = part.getSize(unit="MB")
drive = part.geometry.device.path[5:]

spec = partRequests.PreexistingPartitionSpec(ptype,
@@ -803,7 +803,7 @@ class Partitions:
break
if used:
break
- size = partedUtils.getPartSizeMB(part)
+ size = part.getSize(unit="MB")

if not used:
rc.append((partname, size, 0))
@@ -929,7 +929,7 @@ class Partitions:
if size is None:
# if we get here, there's no PV data in the partition,
# so clamp the partition's size to 64M
- size = partedUtils.getPartSizeMB(part)
+ size = part.getSize(unit="MB")
size = lvm.clampPVSize(size, 65536)

if used == 0:
diff --git a/textw/partition_text.py b/textw/partition_text.py
index 9598168..0d9b162 100644
--- a/textw/partition_text.py
+++ b/textw/partition_text.py
@@ -145,7 +145,7 @@ class PartitionWindow:
part = disk.next_partition(part)
continue
# ignore the tiny < 1 MB partitions (#119479)
- if getPartSizeMB(part) <= 1.0:
+ if part.getSize(unit="MB") <= 1.0:
if not part.is_active() or not part.get_flag(parted.PARTITION_BOOT):
part = disk.next_partition(part)
continue
--
1.6.1.3

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 02-12-2009, 01:38 PM
Joel Granados
 
Default Removed partedUtils.getPartSizeMB()

looks ok.

----- "David Cantrell" <dcantrell@redhat.com> wrote:

> The parted.Partition object provides getSize() to return the size
> of the partition in a human-readable format.
> ---
> autopart.py | 9 ++++-----
> iw/partition_gui.py | 6 +++---
> partRequests.py | 2 +-
> partedUtils.py | 7 +------
> partitions.py | 6 +++---
> textw/partition_text.py | 2 +-
> 6 files changed, 13 insertions(+), 19 deletions(-)
>
> diff --git a/autopart.py b/autopart.py
> index d6fda51..a88fc13 100644
> --- a/autopart.py
> +++ b/autopart.py
> @@ -119,8 +119,7 @@ def bootAlphaCheckRequirements(part):
> if free.type & parted.PARTITION_FREESPACE:
> break
> free = disk.next_partition(free)
> - if (not free or free.geom.start != 1L or
> - partedUtils.getPartSizeMB(free) < 1):
> + if (not free or free.geom.start != 1L or free.getSize(unit="MB")
> < 1):
> return BOOTALPHA_NO_RESERVED_SPACE
>
> return PARTITION_SUCCESS
> @@ -137,7 +136,7 @@ def printNewRequestsCyl(diskset, newRequest):
> ##
> partedUtils.end_sector_to_cyl(part.geom.dev, part.geom.end)))
>
> def printFreespaceitem(part):
> - return partedUtils.get_partition_name(part), part.geom.start,
> part.geom.end, partedUtils.getPartSizeMB(part)
> + return partedUtils.get_partition_name(part), part.geom.start,
> part.geom.end, part.getSize(unit="MB")
>
> def printFreespace(free):
> print("Free Space Summary:")
> @@ -180,7 +179,7 @@ class partlist:
> def __str__(self):
> retval = ""
> for p in self.parts:
> - retval = retval + " %s %s %s
" %
> (partedUtils.get_partition_name(p),
> partedUtils.get_partition_file_system_type(p),
> partedUtils.getPartSizeMB(p))
> + retval = retval + " %s %s %s
" %
> (partedUtils.get_partition_name(p),
> partedUtils.get_partition_file_system_type(p), p.getSize(unit="MB"))
>
> return retval
>
> @@ -379,7 +378,7 @@ def fitSized(diskset, requests, primOnly = 0,
> newParts = None):
> continue
>
> lvmLog.debug( "Trying partition %s" %
> (printFreespaceitem(part),))
> - partSize = partedUtils.getPartSizeMB(part)
> + partSize = part.getSize(unit="MB")
> # figure out what the request size will be given
> the
> # geometry (#130885)
> requestSectors = long((request.requestSize *
> 1024L * 1024L) / part.disk.dev.sector_size) - 1
> diff --git a/iw/partition_gui.py b/iw/partition_gui.py
> index 5bf359e..4b43751 100644
> --- a/iw/partition_gui.py
> +++ b/iw/partition_gui.py
> @@ -146,7 +146,7 @@ class DiskStripeSlice:
> rc = "Free
"
> else:
> rc = "%s
" % (get_partition_name(self.partition),)
> - rc = rc + "%Ld MB" % (getPartSizeMB(self.partition),)
> + rc = rc + "%Ld MB" % (self.partition.getSize(unit="MB"),)
> return rc
>
> def getDeviceName(self):
> @@ -835,7 +835,7 @@ class PartitionWindow(InstallWindow):
> part = disk.next_partition(part)
> continue
> # ignore the tiny < 1 MB partitions (#119479)
> - if getPartSizeMB(part) <= 1.0:
> + if part.getSize(unit="MB") <= 1.0:
> if not part.is_active() or not
> part.get_flag(parted.PARTITION_BOOT):
> part = disk.next_partition(part)
>
> continue
> @@ -945,7 +945,7 @@ class PartitionWindow(InstallWindow):
>
> part.geom.start))
> self.tree[iter]['End'] =
> str(end_sector_to_cyl(disk.dev,
>
> part.geom.end))
> - size = getPartSizeMB(part)
> + size = part.getSize(unit="MB")
> if size < 1.0:
> sizestr = "< 1"
> else:
> diff --git a/partRequests.py b/partRequests.py
> index 891afdf..fc108f2 100644
> --- a/partRequests.py
> +++ b/partRequests.py
> @@ -521,7 +521,7 @@ class PartitionSpec(RequestSpec):
> if not part:
> # XXX kickstart might still call this before allocating
> the partitions
> raise RuntimeError, "Checking the size of a partition
> which hasn't been allocated yet"
> - return partedUtils.getPartSizeMB(part)
> + return part.getSize(unit="MB")
>
> def doSizeSanityCheck(self):
> """Sanity check that the size of the partition is sane."""
> diff --git a/partedUtils.py b/partedUtils.py
> index ad14a78..cd32c18 100644
> --- a/partedUtils.py
> +++ b/partedUtils.py
> @@ -70,11 +70,6 @@ def getPartSize(partition):
> """Return the size of partition in sectors."""
> return partition.geom.length
>
> -def getPartSizeMB(partition):
> - """Return the size of partition in megabytes."""
> - return (partition.geom.length * partition.geom.dev.sector_size
> - / 1024.0 / 1024.0)
> -
> def getMaxAvailPartSizeMB(part):
> """Return the maximum size this partition can grow to by looking
> at contiguous freespace partitions."""
> @@ -149,7 +144,7 @@ def get_partition_file_system_type(part):
> elif part.fs_type == None:
> return None
> elif (part.get_flag(parted.PARTITION_BOOT) == 1 and
> - getPartSizeMB(part) <= 1 and part.fs_type.name == "hfs"):
> + part.getSize(unit="MB") <= 1 and part.fs_type.name ==
> "hfs"):
> ptype = fsset.fileSystemTypeGet("Apple Bootstrap")
> elif part.fs_type.name == "linux-swap":
> ptype = fsset.fileSystemTypeGet("swap")
> diff --git a/partitions.py b/partitions.py
> index b98a374..97c3271 100644
> --- a/partitions.py
> +++ b/partitions.py
> @@ -419,7 +419,7 @@ class Partitions:
>
> start = part.geom.start
> end = part.geom.end
> - size = partedUtils.getPartSizeMB(part)
> + size = part.getSize(unit="MB")
> drive = part.geometry.device.path[5:]
>
> spec = partRequests.PreexistingPartitionSpec(ptype,
> @@ -803,7 +803,7 @@ class Partitions:
> break
> if used:
> break
> - size = partedUtils.getPartSizeMB(part)
> + size = part.getSize(unit="MB")
>
> if not used:
> rc.append((partname, size, 0))
> @@ -929,7 +929,7 @@ class Partitions:
> if size is None:
> # if we get here, there's no PV data in the
> partition,
> # so clamp the partition's size to 64M
> - size = partedUtils.getPartSizeMB(part)
> + size = part.getSize(unit="MB")
> size = lvm.clampPVSize(size, 65536)
>
> if used == 0:
> diff --git a/textw/partition_text.py b/textw/partition_text.py
> index 9598168..0d9b162 100644
> --- a/textw/partition_text.py
> +++ b/textw/partition_text.py
> @@ -145,7 +145,7 @@ class PartitionWindow:
> part = disk.next_partition(part)
> continue
> # ignore the tiny < 1 MB partitions (#119479)
> - if getPartSizeMB(part) <= 1.0:
> + if part.getSize(unit="MB") <= 1.0:
> if not part.is_active() or not
> part.get_flag(parted.PARTITION_BOOT):
> part = disk.next_partition(part)
>
> continue
> --
> 1.6.1.3
>
> _______________________________________________
> Anaconda-devel-list mailing list
> Anaconda-devel-list@redhat.com
> https://www.redhat.com/mailman/listinfo/anaconda-devel-list

--
Joel Andres Granados
Red Hat / Brno Czech Republic

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 07:35 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org