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