Add "try" and "exception" block in Create Container keyword

Signed-off-by: EliChin <elizaveta@nspcc.ru>
This commit is contained in:
EliChin 2021-07-29 17:58:26 +03:00 committed by EliChin
parent 57fc4874e8
commit 5f1fc77cb2

View file

@ -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' f'container create --policy "{rule}" {basic_acl} {user_headers} --await'
) )
logger.info("Cmd: %s" % createContainerCmd) logger.info("Cmd: %s" % createContainerCmd)
complProc = subprocess.run(createContainerCmd, check=True, universal_newlines=True, try:
stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=300, shell=True) complProc = subprocess.run(createContainerCmd, check=True, universal_newlines=True,
output = complProc.stdout stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=300, shell=True)
logger.info("Output: %s" % output) output = complProc.stdout
cid = _parse_cid(output) logger.info("Output: %s" % output)
logger.info("Created container %s with rule '%s'" % (cid, rule)) cid = _parse_cid(output)
return cid 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') @keyword('Container List')