用 Python 的 subprocess 执行 git clone命令时,出现预期外的 error 信息
ringa_lee
ringa_lee 2017-04-17 17:18:05
0
1
319

用 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?

ringa_lee
ringa_lee

ringa_lee

reply all(1)
黄舟

Because the output of git clone is originally output to standard output.标准输出 上的.

可以通过 p.returncode

You can use p.returncode to determine whether the command is executed successfully🎜
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!