[英]python - capture pandoc error message via subprocess
I am writing some Python code that interacts with pandoc
via the subprocess
module. 我正在编写一些通过subprocess
模块与pandoc
交互的Python代码。 I am, however, having trouble capturing what pandoc
would normally print to the console whenever a command goes wrong. 但是,我无法捕获每当命令出错时通常会在控制台上打印的pandoc
。 For example, I put this command into Terminal: 例如,我将以下命令放入Terminal:
pandoc -N --variable mainfont=Georgia --variable sansfont=Arial --variable monofont="Bitstream Vera Sans Mono" --variable fontsize=12pt --variable version=1.10 README.txt --latex-engine=xelatex --toc -o README.pdf
And pandoc
then spits out this error message: 然后pandoc
吐出此错误消息:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
!
! The font "Bitstream Vera Sans Mono" cannot be found.
!
! See the fontspec documentation for further information.
!
! For immediate help type H .
!...............................................
l.20 ...apping=tex-ansi]{Bitstream Vera Sans Mono}
pandoc: Error producing PDF from TeX source
Now, I've tried to capture this same error message within my Python code, but to no avail. 现在,我试图在我的Python代码中捕获相同的错误消息,但无济于事。 My current code looks like this: 我当前的代码如下所示:
cmd = ['pandoc', '-N', '--variable=mainfont:Georgia', '--variable=sansfont:Arial', '--variable=monofont:"Bitstream Vera Sans Mono"', '--variable=fontsize:12pt', '--variable=version:1.10', 'README.txt', '--latex-engine=xelatex', '--toc', '--output=README.pdf']
proc = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
print proc
But this only tells me that the command returned non-zero exit status 43
. 但这仅告诉我该命令returned non-zero exit status 43
。 It doesn't print the full (actually informative) error message that I get in the console. 它不会打印出我在控制台中看到的完整的(实际信息丰富的)错误消息。
What am I missing? 我想念什么?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.