From 056ae31ef9fe6c2866c8cf4d883e0b22cac023dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Thu, 27 Jul 2017 09:48:28 +0200 Subject: [PATCH] repoclosure: Fix logging errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of just printing the error directly to stderr, capture the output and use proper logger. This makes sure the error is included in the log file and also fixes `--quiet` option which was not properly honored originally. Signed-off-by: Lubomír Sedlář --- pungi/phases/test.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pungi/phases/test.py b/pungi/phases/test.py index ddc641fc..da7f0562 100644 --- a/pungi/phases/test.py +++ b/pungi/phases/test.py @@ -22,7 +22,7 @@ from pungi.wrappers import repoclosure from pungi.arch import get_valid_arches from pungi.phases.base import PhaseBase from pungi.phases.gather import get_lookaside_repos -from pungi.util import rmtree, is_arch_multilib, failable +from pungi.util import is_arch_multilib, failable, temp_dir class TestPhase(PhaseBase): @@ -63,12 +63,16 @@ def run_repoclosure(compose): repos=repos, lookaside=lookaside, arch=arches) # Use temp working directory directory as workaround for # https://bugzilla.redhat.com/show_bug.cgi?id=795137 - tmp_dir = compose.mkdtemp(prefix="repoclosure_") - try: - run(cmd, logfile=compose.paths.log.log_file(arch, "repoclosure-%s" % variant), - show_cmd=True, can_fail=True, workdir=tmp_dir) - finally: - rmtree(tmp_dir) + with temp_dir(prefix='repoclosure_') as tmp_dir: + # Ideally we would want show_cmd=True here to include the + # command in the logfile, but due to a bug in Kobo that would + # cause any error to be printed directly to stderr. + # https://github.com/release-engineering/kobo/pull/26 + try: + run(cmd, logfile=compose.paths.log.log_file(arch, "repoclosure-%s" % variant), + workdir=tmp_dir) + except RuntimeError as exc: + compose.log_warning('Repoclosure failed for %s.%s\n%s' % (variant.uid, arch, exc)) compose.log_info("[DONE ] %s" % msg)