Blob Blame History Raw
commit 423f5ee15cb0184d6583b57429ba9cb5bd8cdd35
Author: Valentina Mukhamedzhanova <vmukhame@redhat.com>
Date:   Wed Jun 24 17:05:59 2015 +0200

    Plugin API update: missing_requires, pretty_output_update and promptYN fix. BZ#1188960

diff --git a/output.py b/output.py
index 091b58e..5a73f8e 100755
--- a/output.py
+++ b/output.py
@@ -2795,6 +2795,13 @@ to exit.
             if lastdbv.end_rpmdbversion != rpmdbv:
                 self._rpmdb_warn_checks()
 
+    @staticmethod
+    def pretty_output_restring(restring):
+        for msg in restring:
+            prefix = _('Error: %s')
+            prefix2nd = (' ' * (utf8_width(prefix) - 2))
+            yield (prefix, msg.replace('\n', '\n' + prefix2nd))
+
 
 class DepSolveProgressCallBack:
     """A class to provide text output callback functions for Dependency Solver callback."""
diff --git a/utils.py b/utils.py
index dbcd605..5ba320f 100755
--- a/utils.py
+++ b/utils.py
@@ -393,10 +393,8 @@ class YumUtilBase(YumBaseCli):
             return 0
         elif result == 1:
             # Fatal error
-            for msg in resultmsgs:
-                prefix = _('Error: %s')
-                prefix2nd = (' ' * (utf8_width(prefix) - 2))
-                self.logger.critical(prefix, msg.replace('\n', '\n' + prefix2nd))
+            for prefix, msg in self.pretty_output_restring(resultmsgs):
+                self.logger.critical(prefix, msg)
             if not self.conf.skip_broken:
                 self.verbose_logger.info(_(" You could try using --skip-broken to work around the problem"))
             if not self._rpmdb_warn_checks(out=self.verbose_logger.info, warn=False):
diff --git a/yum/depsolve.py b/yum/depsolve.py
index 797826f..a1aeac3 100644
--- a/yum/depsolve.py
+++ b/yum/depsolve.py
@@ -120,6 +120,7 @@ class Depsolve(object):
 
         self.installedFileRequires = None
         self.installedUnresolvedFileRequires = None
+        self._missing_requires = False
 
     def doTsSetup(self):
         """Sets up the transaction set before it is used."""
@@ -375,6 +376,7 @@ class Depsolve(object):
         return self._prco_req_nfv2req(req[0], req[1], req[2])
             
     def _err_missing_requires(self, reqPo, reqTup):
+        self._missing_requires = True
         if hasattr(self.dsCallback, 'format_missing_requires'):
             msg = self.dsCallback.format_missing_requires(reqPo, reqTup)
             if msg is not None: # PK
diff --git a/yum/plugins.py b/yum/plugins.py
index f34ea19..7034da9 100644
--- a/yum/plugins.py
+++ b/yum/plugins.py
@@ -63,7 +63,7 @@ from yum.i18n import utf8_width
 # API, the major version number must be incremented and the minor version number
 # reset to 0. If a change is made that doesn't break backwards compatibility,
 # then the minor number must be incremented.
-API_VERSION = '2.6'
+API_VERSION = '2.7'
 
 class DeprecatedInt(int):
     """A simple int subclass that is used to check when a deprecated
@@ -416,18 +416,22 @@ class PluginConduit:
         converted_level = logginglevels.logLevelFromErrorLevel(level)
         self.logger.log(converted_level, msg)
 
-    def promptYN(self, msg):
+    def promptYN(self, msg, prompt=None):
         """Return a yes or no response, either from assumeyes already
         being set, or from prompting the user.
 
-        :param msg: the message to prompt the user with
+        :param msg: the message to show to the user
+        :param prompt: the question to ask the user (optional); defaults to 'Is this ok [y/N]: '
         :return: 1 if the response is yes, and 0 if the response is no
         """
         self.info(2, msg)
+        if self._base.conf.assumeno:
+            return False
         if self._base.conf.assumeyes:
-            return 1
+            return True
         else:
-            return self._base.userconfirm()
+            kwargs = {'prompt': prompt} if prompt else {}
+            return bool(self._base.userconfirm(**kwargs))
 
     def getYumVersion(self):
         """Return a string representing the current version of yum."""
@@ -704,6 +708,14 @@ class DepsolvePluginConduit(MainPluginConduit):
         self.resultcode = rescode
         self.resultstring = restring
 
+    @property
+    def missing_requires(self):
+        """Boolean indicating if depsolving failed due to missing dependencies."""
+        return self._base._missing_requires
+
+    def pretty_output_restring(self):
+        return '\n'.join(prefix % msg for prefix, msg in self._base.pretty_output_restring(self.resultstring))
+
 class CompareProvidersPluginConduit(MainPluginConduit):
     """Conduit to compare different providers of packages."""
 
diff --git a/yummain.py b/yummain.py
index 0c7c535..32680a8 100755
--- a/yummain.py
+++ b/yummain.py
@@ -248,10 +248,8 @@ def main(args):
         return base.exit_code
     elif result == 1:
         # Fatal error
-        for msg in resultmsgs:
-            prefix = _('Error: %s')
-            prefix2nd = (' ' * (utf8_width(prefix) - 2))
-            logger.critical(prefix, msg.replace('\n', '\n' + prefix2nd))
+        for prefix, msg in base.pretty_output_restring(resultmsgs):
+            logger.critical(prefix, msg)
         if base._depsolving_failed:
             if not base.conf.skip_broken:
                 verbose_logger.info(_(" You could try using --skip-broken to work around the problem"))
commit 1c883b65432c288ad941a362a49c15a8e4fb74b9
Author: Valentina Mukhamedzhanova <vmukhame@redhat.com>
Date:   Mon Jun 29 16:56:13 2015 +0200

    Add conduit.confList to plugin API

diff --git a/yum/plugins.py b/yum/plugins.py
index 7034da9..6857626 100644
--- a/yum/plugins.py
+++ b/yum/plugins.py
@@ -504,6 +504,17 @@ class PluginConduit:
         """
         return config.getOption(self._conf, section, opt, config.BoolOption(default))
 
+    def confList(self, section, opt, default=None):
+        """Read a boolean value from the plugin's own configuration file
+
+        :param section: configuration file section to read
+        :param opt: option name to read
+        :param default: value to read if the option is missing
+        :return: boolean option value read, or *default* if the option
+            was missing or could not be parsed
+        """
+        return config.getOption(self._conf, section, opt, config.ListOption(default))
+
     def registerPackageName(self, name):
         """Register the name of a package to use.