From 5f1fc77cb29e9cf6d9d58fed91efb2d30134ec6a Mon Sep 17 00:00:00 2001 From: EliChin Date: Thu, 29 Jul 2021 17:58:26 +0300 Subject: [PATCH] Add "try" and "exception" block in Create Container keyword Signed-off-by: EliChin --- robot/resources/lib/neofs.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/robot/resources/lib/neofs.py b/robot/resources/lib/neofs.py index e82c7719..023d3f56 100644 --- a/robot/resources/lib/neofs.py +++ b/robot/resources/lib/neofs.py @@ -292,13 +292,18 @@ def create_container(private_key: str, basic_acl:str, rule:str, user_headers: st f'container create --policy "{rule}" {basic_acl} {user_headers} --await' ) logger.info("Cmd: %s" % createContainerCmd) - complProc = subprocess.run(createContainerCmd, check=True, universal_newlines=True, - stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=300, shell=True) - output = complProc.stdout - logger.info("Output: %s" % output) - cid = _parse_cid(output) - logger.info("Created container %s with rule '%s'" % (cid, rule)) - return cid + try: + complProc = subprocess.run(createContainerCmd, check=True, universal_newlines=True, + stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=300, shell=True) + output = complProc.stdout + logger.info("Output: %s" % output) + cid = _parse_cid(output) + logger.info("Created container %s with rule '%s'" % (cid, rule)) + + return cid + + except subprocess.CalledProcessError as e: + raise Exception("command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output)) @keyword('Container List')