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 10 years ago
parent c7f5f7e6f8
commit 4ef82b2e13

@ -10,11 +10,11 @@
####################################################
clear
echo "---------------------------------------------------------------"
echo "cheRTeX -- a script for processing R-Sweave-LaTeX-TikZ projects"
echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
echo "MMX -- taha.ahmed@mkem.uu.se -- CHEPEC doctoral degree project"
echo "---------------------------------------------------------------"
echo "-----------------------------------------------------------------------"
echo "cheRTeX -- a script for processing R--Sweave/knitr--LaTeX/TikZ projects"
echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
echo "MMXIV -- taha.ahmed@kemi.uu.se -- CHEPEC doctoral degree project"
echo "-----------------------------------------------------------------------"
## If the file .latexmkrc exists in the current directory,
## set the flag ltxmkrc=TRUE
@ -27,16 +27,18 @@ else
echo "--- This job did not request LaTeXMK RC file"
fi
# define some commands
Rfiletype="R"
TeXfiletype="tex"
tikzfiles="*.tikz"
Rnwfiles="*.Rnw"
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
# Check if the argument contains a filetype
# Assumes a complete filename was passed
# (assumes a complete filename was passed)
jobfilename=$1
jobfiletype=${jobfilename#*.} # File extension
jobname=${jobfilename%.*} # Filename without extension part
@ -44,14 +46,14 @@ if [ $# -eq 1 ]; then
echo "<cheRTeX> Detected filename: " $jobname
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
# File extension is *.Rnw
# File extension is indeed "[Rr][Nn][Ww]"
echo "<cheRTeX> Detected *.Rnw extension"
jobfiletype="Rnw"
else
# File extension is not *.Rnw
echo "<cheRTeX> File extension should be *.Rnw"
# File extension is NOT "[Rr][Nn][Ww]"
echo "<cheRTeX> This script only handles *.Rnw files"
echo "<cheRTeX> Terminating..."
exit 1
fi
@ -59,8 +61,27 @@ if [ $# -eq 1 ]; then
# Introducing a short delay to enable on-screen reading of previous echo
/home/taha/chepec/chetex/common/bash/simpledelay.sh 2
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?
## There is no obvious way to tell the difference (apart from reading the *.Rnw file)
## IN ALL KNITR DIRECTORIES, CREATE A FILE NAMED: .knitme
@ -119,23 +140,6 @@ if [ $# -eq 1 ]; then
latexmk -pdf -bibtex $jobname
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
# Either no arguments, or more than one argument
if [ $# -eq 0 ]; then

@ -6,11 +6,13 @@
a="https://mail.google.com"
b="https://rememberthemilk.com"
c="https://chepec.timetask.com"
d="https://keep.google.com/keep/"
# open shiny sample-matrix
# find current port number by reading shiny.port file
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

@ -3,7 +3,6 @@ import os, re
import sys
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
#from email.mime.image import MIMEImage
@ -17,15 +16,16 @@ SMTP_SERVER = 'smtp.gmail.com'
SMTP_PORT = 587
sender = 'taha.sol@gmail.com'
password = "OKWS:pled2XO"
# this may no longer work due to two-factor auth enabled for this account
sender = 'doktorandnamnden@gmail.com'
password = ""
recipient = sys.argv[1]
subject = ''
subject = sys.argv[2] # "Inbjudan till DNs sommarmingel - test" #
message = sys.argv[3]
def main():
msg = MIMEMultipart()
msg['Subject'] = sys.argv[2]
msg['Subject'] = subject
msg['To'] = recipient
msg['From'] = sender
@ -42,21 +42,20 @@ def main():
session.login(sender, password)
#fp = open(sys.argv[4], 'rb')
#msgq = MIMEBase('audio', 'audio')
#msgq.set_payload(fp.read())
#fp.close()
fp = open(sys.argv[4], 'rb')
msgq = MIMEBase('application', 'pdf') # MIMEBase('audio', 'audio')
msgq.set_payload(fp.read())
fp.close()
# Encode the payload using Base64
#encoders.encode_base64(msgq)
encoders.encode_base64(msgq)
# Set the filename parameter
#filename=sys.argv[4]
#msgq.add_header('Content-Disposition', 'attachment', filename=filename)
#msg.attach(msgq)
filename=sys.argv[4]
msgq.add_header('Content-Disposition', 'attachment', filename=filename)
msg.attach(msgq)
# Now send or store the message
qwertyuiop = msg.as_string()
session.sendmail(sender, recipient, qwertyuiop)
session.quit()

Loading…
Cancel
Save