Last active
May 8, 2017 02:39
-
-
Save gka/6e49f4a47fe9ded9f6337377e9b37776 to your computer and use it in GitHub Desktop.
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 | |
cd $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | |
blue=$(tput setaf 4) | |
green=$(tput setaf 2) | |
normal=$(tput sgr0) | |
while ./update.sh | |
do | |
printf "\n${blue}>>> sleeping a little bit before running again... ${normal}\n" | |
string='•••••••••••••••••••••••' | |
while [ -n "$string" ] | |
do | |
# printf "\r\e[41m%s\e[0m " "$string" | |
printf " 😴 ${green}$string ${normal} \r" | |
sleep 2 | |
string=${string#?} | |
done | |
printf "\r 🙂 \n" | |
done | |
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 | |
cd $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | |
blue=$(tput setaf 4) | |
normal=$(tput sgr0) | |
export ROUND=2 | |
export LIVE=1 | |
# export PLAYBACK=20170423-220101 | |
printf "\n${blue}>>> round is set to $ROUND...${normal}\n" | |
printf "\n${blue}>>> downloading index...${normal}\n" | |
./download-index.sh | |
printf "\n${blue}>>> parsing index...${normal}\n" | |
python parse-index.py | |
printf "\n${blue}>>> downloading results...${normal}\n" | |
./download.sh | |
printf "\n${blue}>>> parsing results...${normal}\n" | |
python parse-results.py | |
printf "\n${blue}>>> results json to csv...${normal}\n" | |
node json2csv.js | |
if [ "x$PLAYBACK" != 'x' ]; then | |
printf "\n${blue}>>> using round 1 playback data from $PLAYBACK ${normal}\n" | |
cp ../playback/$PLAYBACK.json.csv ../out/round$ROUND/csv/results-communes.csv | |
fi | |
printf "\n${blue}>>> computing vote totals...${normal}\n" | |
sleep 2 | |
Rscript summarise.R | |
node update-timestamp.js | |
node results-html-table.js | |
printf "\n${blue}>>> rendering maps...${normal}\n" | |
node make-maps.js | |
printf "\n${blue}>>> resizing maps for mobile... ${normal}\n" | |
cd ../out/round$ROUND/jpg | |
for img in map-*.jpg | |
do | |
convert $img -resize 1000x1000 "mobile-$(basename $img)" | |
done | |
cd .. | |
printf "\n${blue}>>> upload maps and json to S3... ${normal}\n" | |
if [ "x$LIVE" == 'x1' ]; then | |
MAXAGE=60 # one minute | |
aws s3 --profile newsgraphics cp --cache-control max-age=$MAXAGE --recursive --acl public-read jpg/ s3://int.nyt.com/newsgraphics/2017/05/french-election/ | |
aws s3 --profile newsgraphics cp --cache-control max-age=$MAXAGE --acl public-read json/departments.json s3://int.nyt.com/newsgraphics/2017/05/french-election/ | |
aws s3 --profile newsgraphics cp --cache-control max-age=$MAXAGE --acl public-read json/total.json s3://int.nyt.com/newsgraphics/2017/05/french-election/ | |
aws s3 --profile newsgraphics cp --cache-control max-age=$MAXAGE --acl public-read csv/results-communes.csv s3://int.nyt.com/newsgraphics/2017/05/french-election/ | |
else | |
printf 'not publishing yet\n' | |
fi | |
printf "\n${blue}>>> all done!${normal}\n" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment