[Yum-devel] [PATCH 4/4] Add --assumeno which does the opposite of --assumeyes.

seth vidal skvidal at fedoraproject.org
Thu Jul 14 17:18:05 UTC 2011


On Thu, 2011-07-14 at 11:45 -0400, James Antill wrote:
> ---
>  cli.py          |   13 ++++++++++---
>  docs/yum.conf.5 |    8 ++++++++
>  yum/__init__.py |    5 +++++
>  yum/config.py   |    1 +
>  4 files changed, 24 insertions(+), 3 deletions(-)
> 
> diff --git a/cli.py b/cli.py
> index c69ec3b..7d332c1 100644
> --- a/cli.py
> +++ b/cli.py
> @@ -25,7 +25,7 @@ import sys
>  import time
>  import random
>  import logging
> -from optparse import OptionParser,OptionGroup
> +from optparse import OptionParser,OptionGroup,SUPPRESS_HELP
>  import rpm
>  
>  from weakref import proxy as weakref
> @@ -491,7 +491,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
>          
>          # confirm with user
>          if self._promptWanted():
> -            if not self.userconfirm():
> +            if self.conf.assumeno or not self.userconfirm():
>                  self.verbose_logger.info(_('Exiting on user Command'))
>                  return -1
>  
> @@ -1535,7 +1535,10 @@ class YumOptionParser(OptionParser):
>                  
>              # Handle remaining options
>              if opts.assumeyes:
> -                self.base.conf.assumeyes =1
> +                self.base.conf.assumeyes = 1
> +            if opts.assumeno:
> +                self.base.conf.assumeno  = 1
> +                self.base.conf.assumeyes = 0
>  
>              #  Instead of going cache-only for a non-root user, try to use a
>              # user writable cachedir. If that fails fall back to cache-only.
> @@ -1712,6 +1715,10 @@ class YumOptionParser(OptionParser):
>                          help=_("verbose operation"))
>          group.add_option("-y", "--assumeyes", dest="assumeyes",
>                  action="store_true", help=_("answer yes for all questions"))
> +        group.add_option("--assumeno", dest="assumeno",
> +                action="store_true", help=_("answer no for all questions"))
> +        group.add_option("--nodeps", dest="assumeno", # easter egg :)
> +                action="store_true", help=SUPPRESS_HELP)
>          group.add_option("--version", action="store_true", 
>                  help=_("show Yum version and exit"))
>          group.add_option("--installroot", help=_("set install root"), 
> diff --git a/docs/yum.conf.5 b/docs/yum.conf.5
> index 515aa73..d069f06 100644
> --- a/docs/yum.conf.5
> +++ b/docs/yum.conf.5
> @@ -117,6 +117,14 @@ critical actions. Default is `0' (do prompt).
>  Command-line option: \fB\-y\fP
>  
>  .IP
> +\fBassumeno\fR
> +Either `1' or `0'. If yum would prompt for confirmation of critical actions, 
> +assume the user chose no. This is basically the same as doing "echo | yum ..."
> +but is a bit more usable. Default is `0' (do prompt).
> +.br
> +Command-line option: \fB\--assumeno\fP
> +
> +.IP
>  \fBalwaysprompt\fR
>  Either `1' or `0'. Without this option, yum will not prompt for confirmation
>  when the list of packages to be installed exactly matches those given on the
> diff --git a/yum/__init__.py b/yum/__init__.py
> index e9bc1f9..8951cdc 100644
> --- a/yum/__init__.py
> +++ b/yum/__init__.py
> @@ -4729,6 +4729,8 @@ class YumBase(depsolve.Depsolve):
>                      rc = False
>                      if self.conf.assumeyes:
>                          rc = True
> +                    elif self.conf.assumeno:
> +                        rc = False
>                          
>                      # grab the .sig/.asc for the keyurl, if it exists
>                      # if it does check the signature on the key
> @@ -4823,6 +4825,9 @@ class YumBase(depsolve.Depsolve):
>                      rc = False
>                      if self.conf.assumeyes:
>                          rc = True
> +                    elif self.conf.assumeno:
> +                        rc = False
> +
>                      elif callback:
>                          rc = callback({"repo": repo, "userid": info['userid'],
>                                          "hexkeyid": info['hexkeyid'], "keyurl": keyurl,
> diff --git a/yum/config.py b/yum/config.py
> index dca13fa..dbf1784 100644
> --- a/yum/config.py
> +++ b/yum/config.py
> @@ -664,6 +664,7 @@ class YumConf(StartupConf):
>      tsflags = ListOption()
>  
>      assumeyes = BoolOption(False)
> +    assumeno  = BoolOption(False)
>      alwaysprompt = BoolOption(True)
>      exactarch = BoolOption(True)
>      tolerant = BoolOption(True)


looks like assumeyes wins when both are set?

ACK

-sv




More information about the Yum-devel mailing list