mirror of
https://github.com/mghansen256/pythontex-wrapper.git
synced 2024-10-27 20:34:03 +00:00
Better error reporting and simplified code.
This commit is contained in:
parent
388bddd1c8
commit
dc3687f5f2
@ -20,25 +20,41 @@ fi
|
||||
# print some debug information
|
||||
echo "pythontex-wrapper.sh"
|
||||
echo "arguments:" $@
|
||||
logfilename=`basename $1 .tex`.log
|
||||
basefilename=`basename $1 .tex`
|
||||
logfilename=${basefilename}.log
|
||||
pytxcodefilename=${basefilename}.pytxcode
|
||||
echo "Log file: " ${logfilename}
|
||||
echo "Working directory: " `pwd`
|
||||
echo "Using latex command: " ${latexcommand}
|
||||
echo "Using pythontex command: " ${pythontexcommand}
|
||||
|
||||
# compile using latex
|
||||
if ${latexcommand} $@ ; then
|
||||
# compilation in latex worked, run pythontex3
|
||||
if ${pythontexcommand} $1 ; then
|
||||
# pythontex worked, run latex again
|
||||
if ${latexcommand} $@ ; then
|
||||
# compilation in latex worked
|
||||
exit 0
|
||||
else
|
||||
echo -e "\n\npythontex-wrapper: Calling ${latexcommand}"
|
||||
echo -e "------------------------------------------\n\n"
|
||||
${latexcommand} $@
|
||||
lastResult=$?
|
||||
echo "First latex run: ${lastResult}" >> pythontex-wrapper.log
|
||||
if [ $lastResult -gt 0 ] ; then
|
||||
# compilation using latex failed
|
||||
echo "pythontex-wrapper: This was the first latex run, before pythontex was called!" >> ${logfilename}
|
||||
echo "pythontex-wrapper: pythontex may have been run previously by lyx, before bibtex was run." >> ${logfilename}
|
||||
echo "pythontex-wrapper: If the problem was due to bad python output and persists after fixing it," >> ${logfilename}
|
||||
echo "pythontex-wrapper: please delete the pythontex-file-${basefilename} folder in the output directory." >> ${logfilename}
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
|
||||
# compilation in latex worked, run pythontex3 if needed
|
||||
if [ ! -e ${pytxcodefilename} ] ; then
|
||||
echo "pythontex-wrapper: No pytxcode file generated, no need to run pythontex!" | tee -a ${logfilename}
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo -e "\n\npythontex-wrapper: Calling ${pythontexcommand}"
|
||||
echo -e "------------------------------------------\n\n"
|
||||
${pythontexcommand} $1
|
||||
lastResult=$?
|
||||
echo "pythontex run: ${lastResult}" >> pythontex-wrapper.log
|
||||
if [ ${lastResult} -gt 0 ]; then
|
||||
# running pythontex failed
|
||||
# lyx expects LaTeX error messages in the log file
|
||||
# Add a fake latex error message which lyx understands
|
||||
@ -48,7 +64,18 @@ if ${latexcommand} $@ ; then
|
||||
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
|
||||
# pythontex worked, run latex again
|
||||
echo -e "\n\npythontex-wrapper: Calling ${latexcommand}"
|
||||
echo -e "------------------------------------------\n\n"
|
||||
${latexcommand} $@
|
||||
lastResult=$?
|
||||
echo "Second latex run: ${lastResult}" >> pythontex-wrapper.log
|
||||
echo "pythontex-wrapper: This was the second latex run, after pythontex was called!" >> ${logfilename}
|
||||
if [ ${lastResult} -gt 0 ] ; then
|
||||
# compilation using latex failed
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# compilation in latex worked
|
||||
exit 0
|
||||
|
Loading…
Reference in New Issue
Block a user