Sweave/LaTeXドキュメントをPDFに変換するためのPythonスクリプトを作成しました。Pythonでos.system呼び出しによって生成されたLaTeX警告/エラーを検出して処理する
os.system("""echo "Sweave('%s.Rnw')" | R --vanilla --quiet"""%topic)
seq = ['p','b','p','b','p','p']
for op in seq:
if op is 'p':
os.system('pdflatex %s'%topic)
if op is 'b':
os.system('bibtex %s'%topic)
if op is 'l':
os.system('latex %s'%topic)
エラーがない場合、これは素晴らしい作品が、LaTeXの誤差がある場合、私はLaTeXの例のためのCLIにもたらしています、
[10]
! You can't use `macro parameter character #' in vertical mode.
l.625 #
?
私は、必要があります。ここで最も重要な部分ですこれを手動で打ち破る。 os.system呼び出しがLaTeXでエラーを生成し、この呼び出しを終了してもエラーテキストを捕捉していることをPythonに「知らせる」方法がありますか?
Pythonでエラーテキストをキャプチャする方法を見つけましたか? – benregn
はい - を使用してエラーメッセージにアクセスできます。pdftex_process = subprocess.Popen(['pdflatex'、 '-interaction = nonstopmode'、 '%s'%topic]、shell = False、stdout = subprocess.PIPE) ()メソッドをpdftex_processオブジェクトに追加します。 –