From e2e8df3f09f72ceda59a6caa6b7ece068fa5cc51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Wed, 26 Sep 2018 14:13:35 +0200 Subject: [PATCH] gather: Hide pid of fus process MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There's an environment variable that can suppress printing of PID for every debug message. It provides us with no real information and only makes the log larger. JIRA: COMPOSE-2973 Signed-off-by: Lubomír Sedlář --- pungi/phases/gather/methods/method_hybrid.py | 7 +++- tests/test_gather_method_hybrid.py | 36 +++++++++++++++----- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/pungi/phases/gather/methods/method_hybrid.py b/pungi/phases/gather/methods/method_hybrid.py index e3f836c6..4e469df4 100644 --- a/pungi/phases/gather/methods/method_hybrid.py +++ b/pungi/phases/gather/methods/method_hybrid.py @@ -208,7 +208,12 @@ class GatherMethodHybrid(pungi.phases.gather.method.GatherMethodBase): logfile = self.compose.paths.log.log_file( arch, "hybrid-depsolver-%s-iter-%d" % (variant, step) ) - run(cmd, logfile=logfile, show_cmd=True) + # Adding this environement variable will tell GLib not to prefix + # any log messages with the PID of the fus process (which is quite + # useless for us anyway). + env = os.environ.copy() + env["G_MESSAGES_PREFIXED"] = "" + run(cmd, logfile=logfile, show_cmd=True, env=env) output = fus.parse_output(logfile) new_multilib = self.add_multilib(variant, arch, output) if new_multilib: diff --git a/tests/test_gather_method_hybrid.py b/tests/test_gather_method_hybrid.py index c6d7d0da..551a4451 100644 --- a/tests/test_gather_method_hybrid.py +++ b/tests/test_gather_method_hybrid.py @@ -331,7 +331,11 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase): self.assertEqual(po.call_args_list, [mock.call(self.logfile1)]) self.assertEqual( run.call_args_list, - [mock.call(gc.return_value, logfile=self.logfile1, show_cmd=True)], + [ + mock.call( + gc.return_value, logfile=self.logfile1, show_cmd=True, env=mock.ANY + ) + ], ) self.assertEqual( gc.call_args_list, @@ -360,7 +364,11 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase): self.assertEqual(po.call_args_list, [mock.call(self.logfile1)]) self.assertEqual( run.call_args_list, - [mock.call(gc.return_value, logfile=self.logfile1, show_cmd=True)], + [ + mock.call( + gc.return_value, logfile=self.logfile1, show_cmd=True, env=mock.ANY + ) + ], ) self.assertEqual( gc.call_args_list, @@ -386,8 +394,12 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase): self.assertEqual( run.call_args_list, [ - mock.call(gc.return_value, logfile=self.logfile1, show_cmd=True), - mock.call(gc.return_value, logfile=self.logfile2, show_cmd=True), + mock.call( + gc.return_value, logfile=self.logfile1, show_cmd=True, env=mock.ANY + ), + mock.call( + gc.return_value, logfile=self.logfile2, show_cmd=True, env=mock.ANY + ), ], ) self.assertEqual( @@ -448,8 +460,12 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase): self.assertEqual( run.call_args_list, [ - mock.call(gc.return_value, logfile=self.logfile1, show_cmd=True), - mock.call(gc.return_value, logfile=self.logfile2, show_cmd=True), + mock.call( + gc.return_value, logfile=self.logfile1, show_cmd=True, env=mock.ANY + ), + mock.call( + gc.return_value, logfile=self.logfile2, show_cmd=True, env=mock.ANY + ), ], ) self.assertEqual( @@ -541,8 +557,12 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase): self.assertEqual( run.call_args_list, [ - mock.call(gc.return_value, logfile=self.logfile1, show_cmd=True), - mock.call(gc.return_value, logfile=self.logfile2, show_cmd=True), + mock.call( + gc.return_value, logfile=self.logfile1, show_cmd=True, env=mock.ANY + ), + mock.call( + gc.return_value, logfile=self.logfile2, show_cmd=True, env=mock.ANY + ), ], ) self.assertEqual(