From 77ae94a214731a39132744aa7ff6fce69e2a1fd2 Mon Sep 17 00:00:00 2001 From: Uri Lublin Date: Thu, 20 Feb 2020 16:54:14 +0200 Subject: [PATCH] migrate.py: python3: when there is no output do not print the heading Also don't try to decode a possibly None value. Signed-off-by: Uri Lublin --- tests/migrate.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/migrate.py b/tests/migrate.py index 8ecb59fd..36a2db89 100755 --- a/tests/migrate.py +++ b/tests/migrate.py @@ -216,9 +216,13 @@ class Migrator(object): dead.wait() new_spice_port = dead.spice_port new_qmp_filename = dead.qmp_filename - self.log.write("# STDOUT dead %s\n" % dead.pid) - outstr = dead.stdout.read().decode(encoding='utf-8', errors='ignore') - self.log.write(outstr) + + outstr = dead.stdout.read() + if outstr: + outstr = outstr.decode(encoding='utf-8', errors='ignore') + self.log.write("# STDOUT dead %s\n" % dead.pid) + self.log.write(outstr) + del dead self.active = self.target self.target = start_qemu(spice_port=new_spice_port,