Added support for knitr jobs as well.

chertex.sh will use knitr instead of pgfSweave if it detects a file name ".knitme"
in the directory of the current job. Crude solution, but it should work.
master
Taha Ahmed 12 years ago
parent 724ebff898
commit 95164fa0a3

@ -59,20 +59,49 @@ if [ $# -eq 1 ]; then
# Introducing a short delay to enable on-screen reading of previous echo # Introducing a short delay to enable on-screen reading of previous echo
simpledelay.sh 2 simpledelay.sh 2
echo "Delay completed" echo "Delay completed"
# Tangle ## Handle knitr or pgfSweave jobs separately
echo "<cheRTeX> Tangling..." ## But how should we tell the difference between them?
R CMD Stangle $jobname.$jobfiletype ## There is no obvious way to tell the difference (apart from reading the *.Rnw file)
# Weave ## IN ALL KNITR DIRECTORIES, CREATE A FILE NAMED: .knitme
echo "<cheRTeX> Weaving..." # If the file .knitme exists in the current directory,
R CMD pgfsweave --graphics-only $jobname.$jobfiletype # run knitr commands, otherwise run pgfsweave commands
echo "--- Looking for .knitme"
# Introduce delay to give time to read R CMD exit status if [ -e .knitme ]; then
echo "<cheRTeX> -------------------------" # Run knitr commands for this job
echo "<cheRTeX> R CMD pgfsweave completed" echo "<cheRTeX> -----------------------"
echo "<cheRTeX> -------------------------" echo "<cheRTeX> This is a job for knitr"
simpledelay.sh 4 echo "<cheRTeX> -----------------------"
# Knit
echo "<cheRTeX> Knitting..."
Rscript -e "library(knitr); library(methods); knit('$jobname.$jobfiletype')"
# Introduce delay to give time to read Rscript exit status
echo "<cheRTeX> -----------------------"
echo "<cheRTeX> Rscript knitr completed"
echo "<cheRTeX> -----------------------"
simpledelay.sh 4
else
# Run pgfSweave commands
echo "<cheRTeX> ---------------------------"
echo "<cheRTeX> This is a job for pgfSweave"
echo "<cheRTeX> ---------------------------"
# Tangle
echo "<cheRTeX> Tangling..."
R CMD Stangle $jobname.$jobfiletype
# Weave
echo "<cheRTeX> Weaving..."
R CMD pgfsweave --graphics-only $jobname.$jobfiletype
# Introduce delay to give time to read R CMD exit status
echo "<cheRTeX> -------------------------"
echo "<cheRTeX> R CMD pgfsweave completed"
echo "<cheRTeX> -------------------------"
simpledelay.sh 4
fi
# Run vc script if vc exists in working directory # Run vc script if vc exists in working directory
echo "<cheRTeX> Running vc script" echo "<cheRTeX> Running vc script"
if [ -f vc ]; then if [ -f vc ]; then
@ -204,6 +233,11 @@ else
if [ $cssfiles != 0 ]; then if [ $cssfiles != 0 ]; then
cp /home/taha/chepec/tmp/$tmpdirname/*.css . cp /home/taha/chepec/tmp/$tmpdirname/*.css .
fi fi
# Return .knitme file [empty file used to indicate knitr jobs]
knitmefile=`ls -1 /home/taha/chepec/tmp/$tmpdirname/.knitme 2>/dev/null | wc -l`
if [ $knitmefile != 0 ]; then
cp /home/taha/chepec/tmp/$tmpdirname/.knitme .
fi
fi fi
echo "Terminating..." echo "Terminating..."

Loading…
Cancel
Save