gather: Print profiling information to stderr

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ář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2018-04-25 13:11:31 +02:00
parent 4d53a5c9ca
commit 8c22236ad4
2 changed files with 8 additions and 5 deletions

View File

@ -3,8 +3,9 @@
from __future__ import print_function from __future__ import print_function
import os
import argparse import argparse
import os
import sys
import pungi.ks import pungi.ks
from pungi.dnf_wrapper import DnfWrapper, Conf from pungi.dnf_wrapper import DnfWrapper, Conf
@ -142,7 +143,7 @@ def main(persistdir, cachedir):
else: else:
print_rpms(g) print_rpms(g)
if ns.profiler: if ns.profiler:
Profiler.print_results() Profiler.print_results(stream=sys.stderr)
def _get_flags(gather_obj, pkg): def _get_flags(gather_obj, pkg):

View File

@ -40,6 +40,7 @@ from __future__ import print_function
import functools import functools
import sys
import time import time
@ -66,9 +67,10 @@ class Profiler(object):
return decorated return decorated
@classmethod @classmethod
def print_results(cls): def print_results(cls, stream=sys.stdout):
print("Profiling results:") print("Profiling results:", file=sys.stdout)
results = cls._data.items() results = cls._data.items()
results = sorted(results, key=lambda x: x[1]["time"], reverse=True) results = sorted(results, key=lambda x: x[1]["time"], reverse=True)
for name, data in results: 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)