From af840ed37618b4a238de7327a84020f8837c8bdb Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Tue, 25 Oct 2022 18:01:08 +0300 Subject: [PATCH] [#30] preset: Create missing files Also, stop if none of the container creation commands succeeded. Signed-off-by: Pavel Karpy --- scenarios/preset/preset_grpc.py | 8 ++++---- scenarios/preset/preset_s3.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scenarios/preset/preset_grpc.py b/scenarios/preset/preset_grpc.py index acce582..9ebc86b 100755 --- a/scenarios/preset/preset_grpc.py +++ b/scenarios/preset/preset_grpc.py @@ -68,7 +68,7 @@ def main(): data = {'containers': container_list, 'objects': objects_struct, 'obj_size': args.size + " Kb"} - with open(args.out, 'w') as f: + with open(args.out, 'w+') as f: json.dump(data, f, ensure_ascii=False) print(f"Result:") @@ -77,7 +77,7 @@ def main(): def random_payload(payload_filepath): - with open('%s' % payload_filepath, 'wb') as fout: + with open('%s' % payload_filepath, 'w+b') as fout: fout.write(os.urandom(1024 * int(args.size))) @@ -100,7 +100,7 @@ def create_container(): output, success = execute_cmd(cmd_line) if not success: - print(f" > Container has not been created.") + print(f" > Container has not been created:\n{output}") else: try: fst_str = output.split('\n')[0] @@ -119,7 +119,7 @@ def upload_object(container, payload_filepath): out, success = execute_cmd(cmd_line) if not success: - print(f" > Object {object_name} has not been uploaded.") + print(f" > Object {object_name} has not been uploaded:\n{out}") else: try: # taking second string from command output diff --git a/scenarios/preset/preset_s3.py b/scenarios/preset/preset_s3.py index 2685be6..0247a3e 100755 --- a/scenarios/preset/preset_s3.py +++ b/scenarios/preset/preset_s3.py @@ -66,7 +66,7 @@ def main(): data = {'buckets': bucket_list, 'objects': objects_struct, 'obj_size': args.size + " Kb"} - with open(args.out, 'w') as f: + with open(args.out, 'w+') as f: json.dump(data, f, ensure_ascii=False) print(f"Result:") @@ -75,7 +75,7 @@ def main(): def random_payload(payload_filepath): - with open('%s' % payload_filepath, 'wb') as fout: + with open('%s' % payload_filepath, 'w+b') as fout: fout.write(os.urandom(1024 * int(args.size)))