From 36e8a42813867509b646291a6efd5d83030a71af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Forr=C3=B3?= Date: Fri, 10 Feb 2023 21:07:17 +0100 Subject: [PATCH] Avoid printing any log messages unless log level is DEBUG MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Importing the shim should be silent. If the system RPM module fails to import, ImportError will be raised, and that makes it clear that the process failed. Signed-off-by: Nikola Forró --- rpm/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rpm/__init__.py b/rpm/__init__.py index 967a66f..17c8e6b 100644 --- a/rpm/__init__.py +++ b/rpm/__init__.py @@ -88,10 +88,13 @@ def initialize() -> None: except ShimAlreadyInitializingError: continue except Exception as e: - logger.error(f"Exception: {e}") + logger.debug(f"Exception: {type(e)}: {e}") continue else: - raise ImportError("Failed to import system RPM module") + raise ImportError( + "Failed to import system RPM module. " + "Make sure RPM Python bindings are installed on your system." + ) # avoid repeated initialization of the shim module