Skip to content

Commit fd10681

Browse files
committed
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 <tatiana@nspcc.io>
1 parent 735b7ca commit fd10681

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

scenarios/preset/helpers/neofs_cli.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,17 @@ def create_container(endpoint, policy, wallet_file, wallet_config):
1313
print(f" > Container has not been created:\n{output}")
1414
return False
1515
else:
16-
try:
17-
fst_str = output.split('\n')[0]
18-
except Exception:
19-
print(f"Got empty output: {output}")
20-
return False
21-
splitted = fst_str.split(": ")
22-
if len(splitted) != 2:
23-
raise ValueError(f"no CID was parsed from command output: \t{fst_str}")
24-
25-
print(f"Created container: {splitted[1]}")
26-
27-
return splitted[1]
16+
# Regular expression to find the container ID, case-insensitive
17+
pattern = r"container ID: ([A-Za-z0-9]{44})"
18+
19+
# Search for the pattern in the output text with case-insensitive flag
20+
match = re.search(pattern, output, re.IGNORECASE)
21+
if match:
22+
container_id = match.group(1)
23+
print(f"Created container: {container_id}")
24+
return container_id
25+
else:
26+
raise ValueError(f"no CID was parsed from command output: \t{output}")
2827

2928

3029
def upload_object(container, payload_filepath, endpoint, wallet_file, wallet_config):

0 commit comments

Comments
 (0)