Last active
November 5, 2015 09:57
-
-
Save jvperrin/00ddba5241f814431275 to your computer and use it in GitHub Desktop.
A semi-fancy script to automate submission of EE 16A homework assignments and self-grades.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
HW_NAME=$(basename "$PWD") | |
if [[ $HW_NAME == *"grades" ]] | |
then | |
echo "Submitting self-grades!" | |
echo "Uploading the grades to the instructional servers..." | |
ssh ee16a "mkdir -p ~/classes/ee16a/$HW_NAME" | |
scp $HW_NAME.txt ee16a:~/classes/ee16a/$HW_NAME/ | |
else | |
echo "Submitting a homework assignment!" | |
# Ask about IPython submission | |
while true; do | |
read -p "Are you submitting a non-empty IPython notebook? (y/n) " yn | |
case $yn in | |
[Yy]* ) IPYNB=true; break;; | |
[Nn]* ) IPYNB=false; break;; | |
* ) echo "Please answer yes or no.";; | |
esac | |
done | |
# Check first that the pdf does not already exist before creating it | |
if [ ! -f "$HW_NAME.pdf" ] | |
then | |
echo "Making a pdf of the photos..." | |
# Find all image files and convert them into a pdf | |
convert $(find . -type f -exec file {} \; | awk -F: '{ if ($2 ~/image/) print $1}') uncompressed.pdf | |
echo "Compressing the pdf..." | |
pdf2ps uncompressed.pdf output.ps | |
ps2pdf output.ps $HW_NAME.pdf | |
rm uncompressed.pdf output.ps | |
else | |
echo "The pdf already exists, so no need to make it again" | |
fi | |
echo "Uploading the pdf to the instructional servers..." | |
ssh ee16a "mkdir -p ~/classes/ee16a/$HW_NAME" | |
if [ "$IPYNB" = true ] | |
then | |
scp $HW_NAME.pdf $HW_NAME.ipynb ee16a:~/classes/ee16a/$HW_NAME/ | |
else | |
scp $HW_NAME.pdf ee16a:~/classes/ee16a/$HW_NAME/ | |
ssh ee16a "touch ~/classes/ee16a/$HW_NAME/$HW_NAME.ipynb" | |
fi | |
fi | |
echo "Submitting documents..." | |
ssh ee16a " | |
cd ~/classes/ee16a/$HW_NAME | |
submit $HW_NAME | |
echo 'Submitted successfully! Time submitted:' | |
glookup -t | grep $HW_NAME | |
" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
does this ask for your ssh password every time it runs a remote command?