#NEWLINE# def tex2pdf( out_path ) : #NEWLINE# #INDENT# import subprocess #NEWLINE# command_line = 'pdflatex -halt-on-error paper.tex' #NEWLINE# dummy = tempfile . TemporaryFile ( ) #NEWLINE# run = subprocess . Popen ( command_line , shell = True , stdin = dummy , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = out_path ) #NEWLINE# ( out , err ) = run . communicate ( ) #NEWLINE# if ( ( 'Fatal' in out ) or run . returncode ) : #NEWLINE# #INDENT# print ( 'PDFLaTeX error output:' ) #NEWLINE# print ( ( '=' * 80 ) ) #NEWLINE# print ( out ) #NEWLINE# print ( ( '=' * 80 ) ) #NEWLINE# if err : #NEWLINE# #INDENT# print ( err ) #NEWLINE# print ( ( '=' * 80 ) ) #NEWLINE# #UNINDENT# return out #NEWLINE# #UNINDENT# stats_file = os . path . join ( out_path , 'paper_stats.json' ) #NEWLINE# d = options . cfg2dict ( stats_file ) #NEWLINE# bib_file = os . path . join ( out_path , ( d [ 'bibliography' ] + '.bib' ) ) #NEWLINE# if os . path . exists ( bib_file ) : #NEWLINE# #INDENT# bibtex_cmd = ( 'bibtex paper && ' + command_line ) #NEWLINE# run = subprocess . Popen ( bibtex_cmd , shell = True , stdin = dummy , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = out_path ) #NEWLINE# ( out , err ) = run . communicate ( ) #NEWLINE# if dummy : #NEWLINE# #INDENT# print ( 'Error compiling BiBTeX' ) #NEWLINE# return out #NEWLINE# #UNINDENT# #UNINDENT# if ( not run . returncode ) : #NEWLINE# #INDENT# run = subprocess . Popen ( command_line , shell = True , stdin = dummy , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = out_path ) #NEWLINE# ( out , err ) = run . communicate ( ) #NEWLINE# #UNINDENT# return out