diff --git a/Automation/data-refresh.sh b/Automation/data-refresh.sh index 125a71a..d3ca233 100755 --- a/Automation/data-refresh.sh +++ b/Automation/data-refresh.sh @@ -14,6 +14,7 @@ handle_failure() { then # failure in preprocessing, bad data might have been written to file git restore . + aws sns publish --topic-arn arn:aws:sns:us-east-2:637423600104:Armchair-Strategist --message file://./Automation/data-refresh.log --subject "Data Refresh Failure - $error_line: $error_command" elif [[ "$error_command" == *readme_machine.py* ]] then # failure in making README graphics, withhold all graph updates only @@ -21,12 +22,16 @@ handle_failure() { git add . git commit -m "Partial data refresh (no visualizations)" || true # ignore non-zero exit status when there's no diff on main ./Automation/auto-push.exp -d 2>./Automation/auto-push.log + aws sns publish --topic-arn arn:aws:sns:us-east-2:637423600104:Armchair-Strategist --message file://./Automation/data-refresh.log --subject "Data Refresh Failure - $error_line: $error_command" + elif [[ "$error_command" == *reddit_machine.py* ]] + then + # failure in Reddit publishing, release all other data and emit warning + ./Automation/auto-push.exp -d 2>./Automation/auto-push.log + aws sns publish --topic-arn arn:aws:sns:us-east-2:637423600104:Armchair-Strategist --message file://./Automation/data-refresh.log --subject "Reddit Publication Warning" fi # relaunch server ./Automation/start-server.sh - - aws sns publish --topic-arn arn:aws:sns:us-east-2:637423600104:Armchair-Strategist --message file://./Automation/data-refresh.log --subject "Data Refresh Failure - $error_line: $error_command" } trap handle_failure ERR trap handle_failure SIGTERM @@ -40,6 +45,12 @@ python3 f1_visualization/preprocess.py python3 f1_visualization/readme_machine.py --update-readme >/dev/null git add . git commit -m "Automatic data refresh" || true # ignore non-zero exit status when there's no diff on main + +# post to Reddit when there is new graphics available +if git status -u | grep -q "Your branch is ahead"; then + python3 reddit_machine.py +fi + ./Automation/auto-push.exp -d 2>./Automation/auto-push.log # relaunch dash app