From a344a9b3758518aa15beed0d36569ec05a76ed2a Mon Sep 17 00:00:00 2001 From: Niels Thykier Date: Sun, 1 Apr 2018 11:26:40 +0000 Subject: [PATCH] Rewrite handling of logging old libraries Signed-off-by: Niels Thykier --- britney.py | 10 +++++----- britney2/utils.py | 8 +++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/britney.py b/britney.py index 773e384..c55ffca 100755 --- a/britney.py +++ b/britney.py @@ -201,7 +201,7 @@ from britney2.migrationitem import MigrationItem from britney2.policies import PolicyVerdict from britney2.policies.policy import AgePolicy, RCBugPolicy, PiupartsPolicy, BuildDependsPolicy from britney2.policies.autopkgtest import AutopkgtestPolicy -from britney2.utils import (old_libraries_format, undo_changes, +from britney2.utils import (log_and_format_old_libraries, undo_changes, compute_reverse_tree, possibly_compressed, read_nuninst, write_nuninst, write_heidi, format_and_log_uninst, newly_uninst, make_migrationitem, @@ -2532,16 +2532,16 @@ class Britney(object): if self.options.smooth_updates: self.logger.info("> Removing old packages left in testing from smooth updates") if removals: - self.output_write("Removing packages left in testing for smooth updates (%d):\n%s" % \ - (len(removals), old_libraries_format(removals))) + self.output_logger.info("Removing packages left in testing for smooth updates (%d):", len(removals)) + log_and_format_old_libraries(self.output_logger, removals) self.do_all(actions=removals) removals = old_libraries(self.sources, self.binaries, self.options.outofsync_arches) else: self.logger.info("> Not removing old packages left in testing from smooth updates" " (smooth-updates disabled)") - self.output_write("List of old libraries in testing (%d):\n%s" % \ - (len(removals), old_libraries_format(removals))) + self.output_logger.info("List of old libraries in testing (%d):", len(removals)) + log_and_format_old_libraries(self.output_logger, removals) self.assert_nuninst_is_correct() diff --git a/britney2/utils.py b/britney2/utils.py index 5a74e40..001f7df 100644 --- a/britney2/utils.py +++ b/britney2/utils.py @@ -164,8 +164,8 @@ def undo_changes(lundo, inst_tester, sources, binaries, all_binary_packages): binaries['testing'][arch][1][provided_pkg] = undo['virtual'][p] -def old_libraries_format(libs): - """Format old libraries in a smart table""" +def log_and_format_old_libraries(logger, libs): + """Format and log old libraries in a table (no header)""" libraries = {} for i in libs: pkg = i.package @@ -173,7 +173,9 @@ def old_libraries_format(libs): libraries[pkg].append(i.architecture) else: libraries[pkg] = [i.architecture] - return "\n".join(" " + k + ": " + " ".join(libraries[k]) for k in libraries) + "\n" + + for lib in sorted(libraries): + logger.info(" %s: %s", lib, " ".join(libraries[lib])) def compute_reverse_tree(inst_tester, affected):