Skip to content

Commit

Permalink
Flush buffers to fix stdout ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
aBozowski committed May 26, 2022
1 parent 3a9012b commit bf89f5a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
24 changes: 12 additions & 12 deletions examples/chef/chef.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def splash() -> None:
| `----.| | | | | |____ | |
\\______||__| |__| |_______||__|{TermColors.STRRESET}
""")
print(splashText)
print(splashText, flush=True)

configFile = f"{_CHEF_SCRIPT_PATH}/config.yaml"

Expand All @@ -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
Expand All @@ -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()

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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):
Expand All @@ -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)
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions examples/chef/chef_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down

0 comments on commit bf89f5a

Please sign in to comment.