From 09fd7a3f6d00f42deb20b1ef0cfa6e3fc13c974e Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Fri, 9 Sep 2022 10:35:01 -0700 Subject: [PATCH] boot-utils: Flush print commands to ensure output is properly ordered Otherwise, when running non-interactively (such as through GitHub Actions), the output from these print statements might not appear before QEMU's output, making it hard to decipher what has gone wrong. Signed-off-by: Nathan Chancellor --- boot-qemu.py | 2 +- utils.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/boot-qemu.py b/boot-qemu.py index 52eb78c..331a986 100755 --- a/boot-qemu.py +++ b/boot-qemu.py @@ -645,7 +645,7 @@ def pretty_print_qemu_cmd(qemu_cmd): qemu_cmd_pretty += " {}".format(element.split("/")[-1]) else: qemu_cmd_pretty += " {}".format(element) - print("$ {}".format(qemu_cmd_pretty.strip())) + print("$ {}".format(qemu_cmd_pretty.strip()), flush=True) def launch_qemu(cfg): diff --git a/utils.py b/utils.py index f627491..63a4db0 100755 --- a/utils.py +++ b/utils.py @@ -73,7 +73,7 @@ def green(string): Parameters: string (str): String to print in bold green. """ - print("\n\033[01;32m{}\033[0m".format(string)) + print("\n\033[01;32m{}\033[0m".format(string), flush=True) def red(string): @@ -83,4 +83,4 @@ def red(string): Parameters: string (str): String to print in bold red. """ - print("\n\033[01;31m{}\033[0m".format(string)) + print("\n\033[01;31m{}\033[0m".format(string), flush=True)