[Yum-devel] [PATCH] Add total removal size, when just doing removes. BZ 495595
Seth Vidal
skvidal at fedoraproject.org
Thu Apr 29 18:01:01 UTC 2010
On Thu, 29 Apr 2010, James Antill wrote:
> ---
> cli.py | 12 ++++++++++--
> output.py | 20 ++++++++++++++++++++
> 2 files changed, 30 insertions(+), 2 deletions(-)
>
> diff --git a/cli.py b/cli.py
> index 2977ca8..2355240 100644
> --- a/cli.py
> +++ b/cli.py
> @@ -416,12 +416,18 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
>
> # Check which packages have to be downloaded
> downloadpkgs = []
> + rmpkgs = []
> stuff_to_download = False
> install_only = True
> + remove_only = True
> for txmbr in self.tsInfo.getMembers():
> if txmbr.ts_state not in ('i', 'u'):
> install_only = False
> + po = txmbr.po
> + if po:
> + rmpkgs.append(po)
> else:
> + remove_only = False
> stuff_to_download = True
> po = txmbr.po
> if po:
> @@ -434,8 +440,10 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
>
> # Report the total download size to the user, so he/she can base
> # the answer on this info
> - if stuff_to_download:
> - self.reportDownloadSize(downloadpkgs, install_only)
> + if not stuff_to_download:
> + self.reportRemoveSize(rmpkgs)
> + else:
> + self.reportDownloadSize(downloadpkgs, install_only, remove_only)
>
> # confirm with user
> if self._promptWanted():
> diff --git a/output.py b/output.py
> index 452f8a2..95564e1 100755
> --- a/output.py
> +++ b/output.py
> @@ -927,6 +927,26 @@ class YumOutput:
> self.verbose_logger.log(logginglevels.INFO_1,
> _("Installed size: %s"),
> self.format_number(insize))
> +
> + def reportRemoveSize(self, packages):
> + """Report the total size of packages being removed. """
> + totsize = 0
> + error = False
> + for pkg in packages:
> + # Just to be on the safe side, if for some reason getting
> + # the package size fails, log the error and don't report download
> + # size
> + try:
> + size = int(pkg.size)
> + totsize += size
> + except:
> + error = True
> + self.logger.error(_('There was an error calculating installed size'))
> + break
> + if (not error):
> + self.verbose_logger.log(logginglevels.INFO_1,
> + _("Installed size: %s"),
> + self.format_number(totsize))
>
> def listTransaction(self):
> """returns a string rep of the transaction in an easy-to-read way."""
ACK
-sv
More information about the Yum-devel
mailing list