[Yum-devel] [PATCH 2/2] If we are only installing, display the amount of disk space used. BZ 487623

Tim Lauridsen tim.lauridsen at googlemail.com
Wed Dec 23 08:50:36 UTC 2009


On Tue, Dec 22, 2009 at 10:18 PM, James Antill <james at and.org> wrote:

> ---
>  cli.py    |    7 +++++--
>  output.py |   16 +++++++++++++++-
>  2 files changed, 20 insertions(+), 3 deletions(-)
>
> diff --git a/cli.py b/cli.py
> index f787968..c563e63 100644
> --- a/cli.py
> +++ b/cli.py
> @@ -375,8 +375,11 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
>         # Check which packages have to be downloaded
>         downloadpkgs = []
>         stuff_to_download = False
> +        install_only = True
>         for txmbr in self.tsInfo.getMembers():
> -            if txmbr.ts_state in ['i', 'u']:
> +            if txmbr.ts_state not in ('i', 'u'):
> +                install_only = False
> +            else:
>                 stuff_to_download = True
>                 po = txmbr.po
>                 if po:
> @@ -390,7 +393,7 @@ 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)
> +            self.reportDownloadSize(downloadpkgs, install_only)
>
>         # confirm with user
>         if self._promptWanted():
> diff --git a/output.py b/output.py
> index 7f92701..e1062d7 100755
> --- a/output.py
> +++ b/output.py
> @@ -864,10 +864,11 @@ class YumOutput:
>     def matchcallback_verbose(self, po, values, matchfor=None):
>         return self.matchcallback(po, values, matchfor, verbose=True)
>
> -    def reportDownloadSize(self, packages):
> +    def reportDownloadSize(self, packages, installonly=False):
>         """Report the total download size for a set of packages"""
>         totsize = 0
>         locsize = 0
> +        insize  = 0
>         error = False
>         for pkg in packages:
>             # Just to be on the safe side, if for some reason getting
> @@ -881,6 +882,15 @@ class YumOutput:
>                         locsize += size
>                 except:
>                     pass
> +
> +                if not installonly:
> +                    continue
> +
> +                try:
> +                    size = int(pkg.installedsize)
> +                except:
> +                    pass
> +                insize += size
>             except:
>                 error = True
>                 self.logger.error(_('There was an error calculating total
> download size'))
> @@ -893,6 +903,10 @@ class YumOutput:
>             if locsize != totsize:
>                 self.verbose_logger.log(logginglevels.INFO_1, _("Total
> download size: %s"),
>                                         self.format_number(totsize -
> locsize))
> +            if installonly:
> +                self.verbose_logger.log(logginglevels.INFO_1,
> +                                        _("Installed size: %s"),
> +                                        self.format_number(insize))
>
>     def listTransaction(self):
>         """returns a string rep of the  transaction in an easy-to-read
> way."""
> --
> 1.6.5.2
>
> _______________________________________________
> Yum-devel mailing list
> Yum-devel at lists.baseurl.org
> http://lists.baseurl.org/mailman/listinfo/yum-devel
>

ACK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.baseurl.org/pipermail/yum-devel/attachments/20091223/0334c953/attachment-0001.htm>


More information about the Yum-devel mailing list