这是函数:
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)
我正在尝试使用此功能先获取erc erc get-login,然后使用返回的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'...)的参数,但是如何实现呢? ?