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 > Redhat > Fedora Design Team

 
 
LinkBack Thread Tools
 
Old 03-21-2012, 12:06 AM
David Lehman
 
Default Add spaceRequired property so YumPayload can tell its disk space needs.

It is the sum of the packages' claimed installed sizes plus 10%.

You have to run checkSoftwareSelection first for it to be at all
realistic.
---
pyanaconda/packaging/yumpayload.py | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)

diff --git a/pyanaconda/packaging/yumpayload.py b/pyanaconda/packaging/yumpayload.py
index 14f3cd5..02a1e11 100644
--- a/pyanaconda/packaging/yumpayload.py
+++ b/pyanaconda/packaging/yumpayload.py
@@ -68,6 +68,8 @@ from pyanaconda.image import opticalInstallMedia
from pyanaconda.image import mountImage
from pyanaconda.image import findFirstIsoImage

+from pyanaconda.storage.size import Size
+
import gettext
_ = lambda x: gettext.ldgettext("anaconda", x)

@@ -120,6 +122,8 @@ class YumPayload(PackagePayload):

self.install_device = None

+ self._space_required = None
+
self._groups = []
self._packages = []

@@ -565,6 +569,7 @@ reposdir=/etc/yum.repos.d,/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/t

super(YumPayload, self).selectGroup(groupid, default=default,
optional=optional)
+ self._space_required = None

def deselectGroup(self, groupid):
# deselect the group in comps
@@ -575,6 +580,7 @@ reposdir=/etc/yum.repos.d,/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/t
raise NoSuchGroup(groupid)

super(YumPayload, self).deselectGroup(groupid)
+ self._space_required = None

###
### METHODS FOR WORKING WITH PACKAGES
@@ -607,6 +613,7 @@ reposdir=/etc/yum.repos.d,/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/t
raise NoSuchPackage(pkgid)

super(YumPayload, self).selectPackage(pkgid)
+ self._space_required = None

def deselectPackage(self, pkgid):
"""Mark a package to be excluded from installation.
@@ -617,6 +624,24 @@ reposdir=/etc/yum.repos.d,/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/t
log.debug("deselect package %s" % pkgid)
self._yum.tsInfo.deselect(pkgid)
super(YumPayload, self).deselectPackage(pkgid)
+ self._space_required = None
+
+ ###
+ ### METHODS FOR QUERYING STATE
+ ###
+ @property
+ def spaceRequired(self):
+ """ The total disk space (Size) required for the current selection. """
+ # XXX this will only be useful if you've run checkSoftwareSelection
+ if not self._space_required:
+ total = 0
+ for txmbr in self._yum.tsInfo.getMembers():
+ total += getattr(txmbr.po, "installedsize", 0)
+
+ total += total * 0.10 # add 10% to account for metadata, &c
+ self._space_required = Size(bytes=total)
+
+ return self._space_required

###
### METHODS FOR INSTALLING THE PAYLOAD
--
1.7.9.3

_______________________________________________
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 02:47 PM.

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