运行 使用 python 脚本的 Helm 命令
Run Helm commands using python script
我想 运行“helm repo add datawire https://app.getambassador.io " using python scripts. I researched and found this link https://github.com/andriisoldatenko/pyhelm/blob/master/pyhelm/repo.py。但我没有发现我需要。你能帮我吗?
如果你想 运行 使用 Python 命令,最好的方法是使用 subprocess
,它非常简单,通常效果很好。
这是一个例子:
import subprocess
subprocess.check_call(['helm', 'repo' 'add', 'datawire', 'https://app.getambassador.io/'])
请注意,这只会调用 helm 客户端并等待它完成。如果您启动的命令 returns 出错,则会抛出 Exception
。
如果您需要命令的 stdout
输出,您可以使用 check_output
.
可以找到子流程文档here
我想 运行“helm repo add datawire https://app.getambassador.io " using python scripts. I researched and found this link https://github.com/andriisoldatenko/pyhelm/blob/master/pyhelm/repo.py。但我没有发现我需要。你能帮我吗?
如果你想 运行 使用 Python 命令,最好的方法是使用 subprocess
,它非常简单,通常效果很好。
这是一个例子:
import subprocess
subprocess.check_call(['helm', 'repo' 'add', 'datawire', 'https://app.getambassador.io/'])
请注意,这只会调用 helm 客户端并等待它完成。如果您启动的命令 returns 出错,则会抛出 Exception
。
如果您需要命令的 stdout
输出,您可以使用 check_output
.
可以找到子流程文档here