这是功能:
def sh(*command, read_output=False, **kwargs):
command_text = " ".join(command)
print(f"\t> {command_text}")
try:
if read_output:
return check_output(command, **kwargs).decode("utf8")
else:
check_call(command, **kwargs)
except CalledProcessError as failure:
print(
f'ERROR: "{command_text}" command reported failure! Return code {failure.returncode}.'
)
sys.exit(failure.returncode)
我正在尝试使用此函数首先获取 aws erc get-login,然后使用返回的登录命令登录到 aws erc。这是我的代码:
result = sh('aws', 'ecr', 'get-login', '--no-include-email', read_output=True)
re = result.split()
sh(re)
然后我得到错误:
command_text = " ".join(command)
TypeError: sequence item 0: expected str instance, list found
我认为该sh
函数期望参数类似于 `('docker', 'login', '-u', 'AWS', '-p'...),但我该如何实现呢?