From fd106812bacf2816ae9c15d4459a60ba9dbe2c77 Mon Sep 17 00:00:00 2001 From: Tatiana Nesterenko Date: Sun, 10 Mar 2024 23:01:03 +0000 Subject: [PATCH] helpers: Use regex to find container ID in neofs_cli output It can find the container ID not just in the first line of the `neofs_cli` output, as the output differs between `aio` and `dev-env`. Signed-off-by: Tatiana Nesterenko --- scenarios/preset/helpers/neofs_cli.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/scenarios/preset/helpers/neofs_cli.py b/scenarios/preset/helpers/neofs_cli.py index 76c242b..26edddd 100644 --- a/scenarios/preset/helpers/neofs_cli.py +++ b/scenarios/preset/helpers/neofs_cli.py @@ -13,18 +13,17 @@ def create_container(endpoint, policy, wallet_file, wallet_config): print(f" > Container has not been created:\n{output}") return False else: - try: - fst_str = output.split('\n')[0] - except Exception: - print(f"Got empty output: {output}") - return False - splitted = fst_str.split(": ") - if len(splitted) != 2: - raise ValueError(f"no CID was parsed from command output: \t{fst_str}") - - print(f"Created container: {splitted[1]}") - - return splitted[1] + # Regular expression to find the container ID, case-insensitive + pattern = r"container ID: ([A-Za-z0-9]{44})" + + # Search for the pattern in the output text with case-insensitive flag + match = re.search(pattern, output, re.IGNORECASE) + if match: + container_id = match.group(1) + print(f"Created container: {container_id}") + return container_id + else: + raise ValueError(f"no CID was parsed from command output: \t{output}") def upload_object(container, payload_filepath, endpoint, wallet_file, wallet_config):