私は、Googleドキュメントの(ラテックスソース)コンテンツをとり、pdfを作成するPythonスクリプトを持っています。 Pythonを使ってLatexコンパイラを実行すると、ラテックスにエラーがあるとハングするのはなぜですか?
この
は、私はPDFファイルに使用する機能です:ラテックスにエラーがない場合# -*- coding: utf-8 -*-
#!/usr/bin/python
"""One of the main activiating files of IMPS - this downloads all the files in a directory, creates the input.tex file and archives them a tar file
TODO
Before we send to stackoverflow we should make sure that everthing is in a function and that the If __main__ trigger is working
I'd also like to have doc strings for all of the methods
"""
import os
import glob
import tarfile
import time
import datetime
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
import urlparse
import argparse
import re
def generate_pdf(filename,destination=""):
"""
Genertates the pdf from string
from http://stackoverflow.com/q/19683123/170243
"""
import subprocess
import shutil
current = os.getcwd()
this_dir=os.path.dirname(os.path.realpath(__file__))
os.chdir(this_dir+"/latex")
proc=subprocess.Popen(['pdflatex',filename+'.tex'],stdout=subprocess.PIPE)
# subprocess.Popen(['pdflatex',tex])
temp=proc.communicate()
#Have to do it twice so that the contents pages are right
proc=subprocess.Popen(['pdflatex',filename+'.tex'],stdout=subprocess.PIPE)
temp=proc.communicate()
shutil.copy(filename+'.pdf',"../../live/"+destination+filename+ str(datetime.datetime.now()).replace(".", "-").replace(":", "_") + ".pdf")
trace_file = open("../../live/"+destination+"trace.txt", "w")
print >>trace_file, temp[0]
print >>trace_file, temp[1]
trace_file.close()
os.chdir(current)
すべてがうまく動作しますが、問題がある場合、関数手と何も行われます。私が望むのは、問題が記録され、トレースにエクスポートされるということです。何が間違っているのでしょうか?
これは私に距離のいくつかを与えます - しかし、コードはそれがリリースする前に私がenterkeyを数回打つことを望んでいます... – Joe
スクラッチ - 私がそれに戻ったときに機能しました。 :) – Joe