repoclosure: Fix logging errors

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ář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2017-07-27 09:48:28 +02:00
parent 99204bb695
commit 056ae31ef9

View File

@ -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)