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

View File

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