dcavalca / rpms / dnf

Forked from rpms/dnf 2 years ago
Clone

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

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