dcavalca / rpms / dnf

Forked from rpms/dnf 2 years ago
Clone

Blame SOURCES/0004-Log-scriptlets-output-also-for-API-users-RhBug-1847340.patch

476404
From df64fd36d7fefe39a96fea3f41e35785bebd37ec Mon Sep 17 00:00:00 2001
476404
From: Marek Blaha <mblaha@redhat.com>
476404
Date: Wed, 2 Dec 2020 16:33:26 +0100
476404
Subject: [PATCH 1/2] Log scriptlets output also for API users (RhBug:1847340)
476404
476404
Messages logged into /var/log/dnf.rpm.log are now the same for both
476404
command line and API usage.
476404
476404
https://bugzilla.redhat.com/show_bug.cgi?id=1847340
476404
---
476404
 dnf/cli/output.py   | 7 +------
476404
 dnf/yum/rpmtrans.py | 9 ++++++++-
476404
 2 files changed, 9 insertions(+), 7 deletions(-)
476404
476404
diff --git a/dnf/cli/output.py b/dnf/cli/output.py
476404
index 51d6829ca6..86260661fc 100644
476404
--- a/dnf/cli/output.py
476404
+++ b/dnf/cli/output.py
476404
@@ -2151,12 +2151,7 @@ def error(self, message):
476404
         pass
476404
 
476404
     def scriptout(self, msgs):
476404
-        """Print messages originating from a package script.
476404
-
476404
-        :param msgs: the messages coming from the script
476404
-        """
476404
-        if msgs:
476404
-            self.rpm_logger.info(ucd(msgs))
476404
+        pass
476404
 
476404
     def _makefmt(self, percent, ts_done, ts_total, progress=True,
476404
                  pkgname=None, wid1=15):
476404
diff --git a/dnf/yum/rpmtrans.py b/dnf/yum/rpmtrans.py
476404
index 447639a476..d6c549d2ed 100644
476404
--- a/dnf/yum/rpmtrans.py
476404
+++ b/dnf/yum/rpmtrans.py
476404
@@ -113,7 +113,10 @@ def progress(self, package, action, ti_done, ti_total, ts_done, ts_total):
476404
         pass
476404
 
476404
     def scriptout(self, msgs):
476404
-        """msgs is the messages that were output (if any)."""
476404
+        """Hook for reporting an rpm scriptlet output.
476404
+
476404
+        :param msgs: the scriptlet output
476404
+        """
476404
         pass
476404
 
476404
     def error(self, message):
476404
@@ -156,6 +159,10 @@ def filelog(self, package, action):
476404
         msg = '%s: %s' % (action_str, package)
476404
         self.rpm_logger.log(dnf.logging.SUBDEBUG, msg)
476404
 
476404
+    def scriptout(self, msgs):
476404
+        if msgs:
476404
+            self.rpm_logger.info(ucd(msgs))
476404
+
476404
 
476404
 class RPMTransaction(object):
476404
     def __init__(self, base, test=False, displays=()):
476404
476404
From ee6ffcf640180b2b08d2db50b4b81d2bdefb1f2f Mon Sep 17 00:00:00 2001
476404
From: Marek Blaha <mblaha@redhat.com>
476404
Date: Thu, 3 Dec 2020 10:08:09 +0100
476404
Subject: [PATCH 2/2] Straighten inheritance of *Display classes
476404
476404
---
476404
 dnf/cli/output.py   | 15 +++------------
476404
 dnf/yum/rpmtrans.py |  2 +-
476404
 2 files changed, 4 insertions(+), 13 deletions(-)
476404
476404
diff --git a/dnf/cli/output.py b/dnf/cli/output.py
476404
index 86260661fc..de188ffbd1 100644
476404
--- a/dnf/cli/output.py
476404
+++ b/dnf/cli/output.py
476404
@@ -37,7 +37,7 @@
476404
 from dnf.cli.format import format_number, format_time
476404
 from dnf.i18n import _, C_, P_, ucd, fill_exact_width, textwrap_fill, exact_width, select_short_long
476404
 from dnf.pycomp import xrange, basestring, long, unicode, sys_maxsize
476404
-from dnf.yum.rpmtrans import LoggingTransactionDisplay
476404
+from dnf.yum.rpmtrans import TransactionDisplay
476404
 from dnf.db.history import MergedTransactionWrapper
476404
 import dnf.base
476404
 import dnf.callback
476404
@@ -2071,7 +2071,7 @@ def short_id(id):
476404
         return self.output.userconfirm()
476404
 
476404
 
476404
-class CliTransactionDisplay(LoggingTransactionDisplay):
476404
+class CliTransactionDisplay(TransactionDisplay):
476404
     """A YUM specific callback class for RPM operations."""
476404
 
476404
     width = property(lambda self: dnf.cli.term._term_width())
476404
@@ -2093,7 +2093,7 @@ def progress(self, package, action, ti_done, ti_total, ts_done, ts_total):
476404
         :param package: the package involved in the event
476404
         :param action: the type of action that is taking place.  Valid
476404
            values are given by
476404
-           :func:`rpmtrans.LoggingTransactionDisplay.action.keys()`
476404
+           :func:`rpmtrans.TransactionDisplay.action.keys()`
476404
         :param ti_done: a number representing the amount of work
476404
            already done in the current transaction
476404
         :param ti_total: a number representing the total amount of work
476404
@@ -2144,15 +2144,6 @@ def _out_progress(self, ti_done, ti_total, ts_done, ts_total,
476404
                 if ti_done == ti_total:
476404
                     print(" ")
476404
 
476404
-    def filelog(self, package, action):
476404
-        pass
476404
-
476404
-    def error(self, message):
476404
-        pass
476404
-
476404
-    def scriptout(self, msgs):
476404
-        pass
476404
-
476404
     def _makefmt(self, percent, ts_done, ts_total, progress=True,
476404
                  pkgname=None, wid1=15):
476404
         l = len(str(ts_total))
476404
diff --git a/dnf/yum/rpmtrans.py b/dnf/yum/rpmtrans.py
476404
index d6c549d2ed..51fa921d3e 100644
476404
--- a/dnf/yum/rpmtrans.py
476404
+++ b/dnf/yum/rpmtrans.py
476404
@@ -143,7 +143,7 @@ def error(self, message):
476404
         dnf.util._terminal_messenger('print', message, sys.stderr)
476404
 
476404
 
476404
-class LoggingTransactionDisplay(ErrorTransactionDisplay):
476404
+class LoggingTransactionDisplay(TransactionDisplay):
476404
     '''
476404
     Base class for a RPMTransaction display callback class
476404
     '''