From 8c22236ad4b7f50da4fbc9449cd88e7e15a9eade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Wed, 25 Apr 2018 13:11:31 +0200 Subject: [PATCH] gather: Print profiling information to stderr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On stdout it gets mixed with listing of gathered packages. This has no effect in a real pungi-koji run, where both streams are merged into a single file which is then parsed, but in manual debugging runs it's a little obnoxious. Signed-off-by: Lubomír Sedlář --- bin/pungi-gather | 5 +++-- pungi/profiler.py | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bin/pungi-gather b/bin/pungi-gather index aa70977b..2546799c 100755 --- a/bin/pungi-gather +++ b/bin/pungi-gather @@ -3,8 +3,9 @@ from __future__ import print_function -import os import argparse +import os +import sys import pungi.ks from pungi.dnf_wrapper import DnfWrapper, Conf @@ -142,7 +143,7 @@ def main(persistdir, cachedir): else: print_rpms(g) if ns.profiler: - Profiler.print_results() + Profiler.print_results(stream=sys.stderr) def _get_flags(gather_obj, pkg): diff --git a/pungi/profiler.py b/pungi/profiler.py index 49bd719e..15f35476 100644 --- a/pungi/profiler.py +++ b/pungi/profiler.py @@ -40,6 +40,7 @@ from __future__ import print_function import functools +import sys import time @@ -66,9 +67,10 @@ class Profiler(object): return decorated @classmethod - def print_results(cls): - print("Profiling results:") + def print_results(cls, stream=sys.stdout): + print("Profiling results:", file=sys.stdout) results = cls._data.items() results = sorted(results, key=lambda x: x[1]["time"], reverse=True) for name, data in results: - print(" %6.2f %5d %s" % (data["time"], data["calls"], name)) + print(" %6.2f %5d %s" % (data["time"], data["calls"], name), + file=sys.stdout)