From bf89f5a16fc47fea4efb45dd7bf22a95dd28e94d Mon Sep 17 00:00:00 2001 From: Austin Bozowski Date: Thu, 26 May 2022 01:33:30 +0000 Subject: [PATCH] Flush buffers to fix stdout ordering --- examples/chef/chef.py | 24 ++++++++++++------------ examples/chef/chef_util.py | 1 + 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/examples/chef/chef.py b/examples/chef/chef.py index 9b6346ad792a43..3cc4084437f4b6 100755 --- a/examples/chef/chef.py +++ b/examples/chef/chef.py @@ -55,7 +55,7 @@ def splash() -> None: | `----.| | | | | |____ | | \\______||__| |__| |_______||__|{TermColors.STRRESET} """) - print(splashText) + print(splashText, flush=True) configFile = f"{_CHEF_SCRIPT_PATH}/config.yaml" @@ -72,7 +72,7 @@ def load_config() -> None: else: print("Running for the first time and configuring config.yaml. " + "Change this configuration file to include correct configuration " + - "for the vendor's SDK") + "for the vendor's SDK", flush=True) configStream = open(configFile, 'w') config["nrfconnect"]["ZEPHYR_BASE"] = os.environ.get('ZEPHYR_BASE') config["nrfconnect"]["TTY"] = None @@ -82,7 +82,7 @@ def load_config() -> None: config["silabs-thread"]["TTY"] = None config["silabs-thread"]["CU"] = None - print(yaml.dump(config)) + print(yaml.dump(config), flush=True) yaml.dump(config, configStream) configStream.close() @@ -244,12 +244,12 @@ def main(argv: Sequence[str]) -> None: print(f"Deleting and recreating existing {chef_zzz_root}") shutil.rmtree(chef_zzz_root) os.mkdir(chef_zzz_root) - print(f"Generating files in {chef_zzz_root} for all devices") + print(f"Generating files in {chef_zzz_root} for all devices", flush=True) for device_dir_item in os.listdir(chef_devices_dir): target_file_ext = ".zap" if device_dir_item.endswith(target_file_ext) and device_dir_item in chef_util.ci_allowlist: device_name = device_dir_item[:-len(target_file_ext)] - print(f"Generating files for {device_name}") + print(f"Generating files for {device_name}", flush=True) device_out_dir = os.path.join(chef_zzz_root, device_name) os.mkdir(device_out_dir) device_out_dir = os.path.join(device_out_dir, "zap-generated") @@ -281,7 +281,7 @@ def main(argv: Sequence[str]) -> None: # if options.build_all: - print("Building all chef examples") + print("Building all chef examples", flush=True) os.environ['GNUARMEMB_TOOLCHAIN_PATH'] = os.environ['PW_ARM_CIPD_INSTALL_DIR'] archive_prefix = "/workspace/artifacts/" if not os.path.exists(archive_prefix): @@ -300,13 +300,13 @@ def main(argv: Sequence[str]) -> None: label = platform_meta['platform_label'] output_dir = os.path.join(_CHEF_SCRIPT_PATH, directory) command = './chef.py -czbr -d {} -t {}'.format(device_name, platform) - print('-' * 64) - print(f"Building {command}") - print('-' * 64) + print('-' * 64, flush=True) + print(f"Building {command}", flush=True) + print('-' * 64, flush=True) subprocess.check_call(command, cwd=_CHEF_SCRIPT_PATH, shell=True) archive_name = f"{label}-chef-{device_name}-wifi-rpc" archive_full_name = archive_prefix + archive_name + archive_suffix - print(f"Adding build output to archive {archive_full_name}") + print(f"Adding build output to archive {archive_full_name}", flush=True) with tarfile.open(archive_full_name, "w:gz") as tar: tar.add(output_dir, arcname=".") exit(0) @@ -370,7 +370,7 @@ def main(argv: Sequence[str]) -> None: f"{_REPO_BASE_PATH}/scripts/tools/zap/run_zaptool.sh {options.sample_device_type_name}.zap") if options.do_run_zap: - print("Running ZAP script to generate artifacts") + print("Running ZAP script to generate artifacts", flush=True) shell.run_cmd(f"mkdir -p {gen_dir}/") shell.run_cmd(f"rm {gen_dir}/*") shell.run_cmd( @@ -400,7 +400,7 @@ def main(argv: Sequence[str]) -> None: if options.do_build: if options.use_zzz: - print("Using pre-generated ZAP output") + print("Using pre-generated ZAP output", flush=True) zzz_dir = os.path.join(_CHEF_SCRIPT_PATH, "zzz_generated", options.sample_device_type_name, "zap-generated") if os.path.exists(gen_dir): shutil.rmtree(gen_dir) diff --git a/examples/chef/chef_util.py b/examples/chef/chef_util.py index 7530be3053c515..3c307dbdf0adf4 100644 --- a/examples/chef/chef_util.py +++ b/examples/chef/chef_util.py @@ -29,6 +29,7 @@ def bundle(platform: str): if platform == 'nrfconnect': pass + def check_zap_master(repo_base_path: str) -> str: """Produces hash of ZAP submodule in branch master""" git_cmd = ["git", "ls-tree", "master", "third_party/zap/repo"]