我正在使用
Python来自动化SVN提交,我想将SVN命令的输出写入日志文件.我有的代码可以使SVN运行,但问题是在成功提交时,子进程调用不会返回我的日志的任何输出.
当我手动运行SVN时,通过比较,我得到输出,显示命令的进度并显示正在提交的文件.这就是我想要的日志文件. SVN是否将数据输出到缓冲区而不是stdout或stderr?如何为我的日志捕获该数据?
这是我正在使用的代码:
cmd = "svn commit --non-interactive --no-auth-cache -m 'Automatic commit' ./"
process = subprocess.Popen(cmd,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True)
result = process.wait()
# Output
out = process.stdout.read()
err = process.stderr.read()
当我运行此代码并且提交成功时,out和err变量都是空的.