用 Python 的 subprocess 执行 git clone命令时,下载过程 31% 66% 100% done这样的正常信息被communicate的 err 捕获,是为什么,如何解决?
output, err = p.communicate()
if output:
logging.info(output)
if err:
logging.error(err)
其中,error 级别的日志,打出了下载进度,最后下载完成了。
但是我不希望这样的成功下载打 error 级别的日志,因为这样会引起告警机制。
如何解决呢? 为什么 git 把下载进度当成了 err 而不是 普通 output?
Because the output of git clone is originally output to
standard output
.标准输出
上的.可以通过
You can usep.returncode
p.returncode
to determine whether the command is executed successfully🎜