运行子进程(例如git push
import subprocess as sp
sp.run(['git', 'push', 'origin', 'HEAD'], stdout=sp.PIPE, stderr=sp.PIPE, check=True)
如果遥控器要求提供凭据(就好像你输错了那样),我希望它抛出一个CalledProcessError
编辑:
@Rex Low:来自CalledProcessError的检查输出的可能重复
即使使用check_output
,它也会在服务终端