chertex.sh now handles sample-matrix jobs only to produce HTML (Shiny) output.

Previously a pdf file was always created as well, but from now on,
sample-matrix will be exclusively used in the Shiny app.
master
Taha Ahmed 11 years ago
parent c7f5f7e6f8
commit 4ef82b2e13

@ -10,11 +10,11 @@
#################################################### ####################################################
clear clear
echo "---------------------------------------------------------------" echo "-----------------------------------------------------------------------"
echo "cheRTeX -- a script for processing R-Sweave-LaTeX-TikZ projects" echo "cheRTeX -- a script for processing R--Sweave/knitr--LaTeX/TikZ projects"
echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
echo "MMX -- taha.ahmed@mkem.uu.se -- CHEPEC doctoral degree project" echo "MMXIV -- taha.ahmed@kemi.uu.se -- CHEPEC doctoral degree project"
echo "---------------------------------------------------------------" echo "-----------------------------------------------------------------------"
## If the file .latexmkrc exists in the current directory, ## If the file .latexmkrc exists in the current directory,
## set the flag ltxmkrc=TRUE ## set the flag ltxmkrc=TRUE
@ -27,16 +27,18 @@ else
echo "--- This job did not request LaTeXMK RC file" echo "--- This job did not request LaTeXMK RC file"
fi fi
# define some commands
Rfiletype="R" Rfiletype="R"
TeXfiletype="tex" TeXfiletype="tex"
tikzfiles="*.tikz" tikzfiles="*.tikz"
Rnwfiles="*.Rnw" Rnwfiles="*.Rnw"
auxfiles="*.aux *.bbl *.bcf *.blg *.fdb* *.figlist *.fls *.lof *.log *.lot *.lox *.makefile *.map *.out *.run* *.tdo *.toc *.dep *.dpth" auxfiles="*.aux *.bbl *.bcf *.blg *.fdb* *.figlist *.fls *.lof *.log *.lot *.lox *.makefile *.map *.out *.run* *.tdo *.toc *.dep *.dpth"
# depending on number of args and their content, do different things...
if [ $# -eq 1 ]; then if [ $# -eq 1 ]; then
# Check if the argument contains a filetype # Check if the argument contains a filetype
# Assumes a complete filename was passed # (assumes a complete filename was passed)
jobfilename=$1 jobfilename=$1
jobfiletype=${jobfilename#*.} # File extension jobfiletype=${jobfilename#*.} # File extension
jobname=${jobfilename%.*} # Filename without extension part jobname=${jobfilename%.*} # Filename without extension part
@ -44,14 +46,14 @@ if [ $# -eq 1 ]; then
echo "<cheRTeX> Detected filename: " $jobname echo "<cheRTeX> Detected filename: " $jobname
echo "<cheRTeX> Detected extension:" $jobfiletype echo "<cheRTeX> Detected extension:" $jobfiletype
# Verifying that the file extension is *.Rnw # Verify that the file extension is "[Rr][Nn][Ww]"
if [[ $jobfiletype == "Rnw" || $jobfiletype == "rnw" || $jobfiletype == "RNW" ]]; then if [[ $jobfiletype == "Rnw" || $jobfiletype == "rnw" || $jobfiletype == "RNW" ]]; then
# File extension is *.Rnw # File extension is indeed "[Rr][Nn][Ww]"
echo "<cheRTeX> Detected *.Rnw extension" echo "<cheRTeX> Detected *.Rnw extension"
jobfiletype="Rnw" jobfiletype="Rnw"
else else
# File extension is not *.Rnw # File extension is NOT "[Rr][Nn][Ww]"
echo "<cheRTeX> File extension should be *.Rnw" echo "<cheRTeX> This script only handles *.Rnw files"
echo "<cheRTeX> Terminating..." echo "<cheRTeX> Terminating..."
exit 1 exit 1
fi fi
@ -59,8 +61,27 @@ 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
/home/taha/chepec/chetex/common/bash/simpledelay.sh 2 /home/taha/chepec/chetex/common/bash/simpledelay.sh 2
echo "Delay completed" echo "Delay completed"
## Handle knitr or pgfSweave jobs separately
#### Special treatment for sample-matrix.Rnw
# If $jobname is sample-matrix, run only knitr and markdown, then exit
if [[ $jobname == "sample-matrix" ]]; then
echo "<cheRTeX> -----------------------------------------------------------"
echo "<cheRTeX> sample-matrix: update SHINY, run knit() + markdownToHTML()"
echo "<cheRTeX> -----------------------------------------------------------"
# Before starting new shiny process, kill any previous instances
pkill -f "shiny::runApp"
bash -c "/home/taha/chepec/chetex/common/bash/shiny-matrix.sh" &
Rscript -e "library(knitr); knit(input='$jobname.Rmd', output='$jobname.md')"
Rscript -e "library(markdown); markdownToHTML('$jobname.md', '$jobname.html', stylesheet = 'custom.css')"
echo "<cheRTeX> Terminating..."
/home/taha/chepec/chetex/common/bash/simpledelay.sh 14
exit 1
fi
## Handle knitr or pgfSweave jobs (each requires separate treatment)
## But how should we tell the difference between them? ## But how should we tell the difference between them?
## There is no obvious way to tell the difference (apart from reading the *.Rnw file) ## There is no obvious way to tell the difference (apart from reading the *.Rnw file)
## IN ALL KNITR DIRECTORIES, CREATE A FILE NAMED: .knitme ## IN ALL KNITR DIRECTORIES, CREATE A FILE NAMED: .knitme
@ -119,23 +140,6 @@ if [ $# -eq 1 ]; then
latexmk -pdf -bibtex $jobname latexmk -pdf -bibtex $jobname
fi fi
## THIS IS A QUICK-AND-DIRTY FIX FOR SAMPLE-MATRIX
# If $jobname is sample-matrix, run knitr and markdown
if [[ $jobname == "sample-matrix" ]]; then
echo "<cheRTeX> -----------------------------------------------------------"
echo "<cheRTeX> sample-matrix: update SHINY, run knit() + markdownToHTML()"
echo "<cheRTeX> -----------------------------------------------------------"
# Old attempts, never worked
#PORT=$(</home/taha/chepec/chetex/sample-matrix/shinyapp/shiny.port)
#bash -c "R -e 'shiny::runApp(\"/home/taha/chepec/chetex/sample-matrix/shinyapp\", port = $PORT)'"
# Before starting new shiny process, kill any previous instances
pkill -f "shiny::runApp"
bash -c "/home/taha/chepec/chetex/common/bash/shiny-matrix.sh" &
Rscript -e "library(knitr); knit(input='$jobname.Rmd', output='$jobname.md')"
Rscript -e "library(markdown); markdownToHTML('$jobname.md', '$jobname.html', stylesheet = 'custom.css')"
fi
else else
# Either no arguments, or more than one argument # Either no arguments, or more than one argument
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then

@ -6,11 +6,13 @@
a="https://mail.google.com" a="https://mail.google.com"
b="https://rememberthemilk.com" b="https://rememberthemilk.com"
c="https://chepec.timetask.com" c="https://chepec.timetask.com"
d="https://keep.google.com/keep/"
# open shiny sample-matrix # open shiny sample-matrix
# find current port number by reading shiny.port file # find current port number by reading shiny.port file
PORT=$(</home/taha/chepec/chetex/sample-matrix/shinyapp/shiny.port) PORT=$(</home/taha/chepec/chetex/sample-matrix/shinyapp/shiny.port)
d="localhost:$PORT" s="localhost:$PORT"
google-chrome $a $b $c $d google-chrome $a $b $c $d $s
exit 1 exit 1

@ -3,7 +3,6 @@ import os, re
import sys import sys
import smtplib import smtplib
# I have commented out the parts that allow sending of attachments...
# I got this code from user hakermania at http://ubuntuforums.org/showthread.php?t=1472520 # I got this code from user hakermania at http://ubuntuforums.org/showthread.php?t=1472520
#from email.mime.image import MIMEImage #from email.mime.image import MIMEImage
@ -17,15 +16,16 @@ SMTP_SERVER = 'smtp.gmail.com'
SMTP_PORT = 587 SMTP_PORT = 587
sender = 'taha.sol@gmail.com' # this may no longer work due to two-factor auth enabled for this account
password = "OKWS:pled2XO" sender = 'doktorandnamnden@gmail.com'
password = ""
recipient = sys.argv[1] recipient = sys.argv[1]
subject = '' subject = sys.argv[2] # "Inbjudan till DNs sommarmingel - test" #
message = sys.argv[3] message = sys.argv[3]
def main(): def main():
msg = MIMEMultipart() msg = MIMEMultipart()
msg['Subject'] = sys.argv[2] msg['Subject'] = subject
msg['To'] = recipient msg['To'] = recipient
msg['From'] = sender msg['From'] = sender
@ -42,21 +42,20 @@ def main():
session.login(sender, password) session.login(sender, password)
#fp = open(sys.argv[4], 'rb') fp = open(sys.argv[4], 'rb')
#msgq = MIMEBase('audio', 'audio') msgq = MIMEBase('application', 'pdf') # MIMEBase('audio', 'audio')
#msgq.set_payload(fp.read()) msgq.set_payload(fp.read())
#fp.close() fp.close()
# Encode the payload using Base64 # Encode the payload using Base64
#encoders.encode_base64(msgq) encoders.encode_base64(msgq)
# Set the filename parameter # Set the filename parameter
#filename=sys.argv[4] filename=sys.argv[4]
#msgq.add_header('Content-Disposition', 'attachment', filename=filename) msgq.add_header('Content-Disposition', 'attachment', filename=filename)
#msg.attach(msgq) msg.attach(msgq)
# Now send or store the message # Now send or store the message
qwertyuiop = msg.as_string() qwertyuiop = msg.as_string()
session.sendmail(sender, recipient, qwertyuiop) session.sendmail(sender, recipient, qwertyuiop)
session.quit() session.quit()

Loading…
Cancel
Save