-
Notifications
You must be signed in to change notification settings - Fork 2
/
generate
executable file
·43 lines (35 loc) · 1.1 KB
/
generate
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
. "$HOME/.local/share/venv/bin/activate"
src_home="${BASH_SOURCE[0]%/*}"
export PYTHONPATH="$src_home:$PYTHONPATH"
if [ -z "$1" ]
then
TARGET="$(date -d tomorrow '+%Y-%m-%d')"
else
TARGET="$1"
fi
printf 'Target: %s\n' "$TARGET"
set -u
if [ "$(date -d "$TARGET" +"%a")" = "Sun" ] || [ "$(date -d "$TARGET" +"%a")" = "Sat" ]
then
printf 'Not generating for weekends, exiting\n' >&2
exit 5
fi
if [ "$(date -d "$TARGET" +"%a")" = "Mon" ]
then
printf 'Target day is a Monday, running weekly.py too\n' >&2
python3 -m sjdbmk.weekly --date="$TARGET" || exit 1
fi
printf 'Running daily.py\n' >&2
python3 -m sjdbmk.daily --date="$TARGET" || exit 2
printf 'Running pack.py\n' >&2
python3 -m sjdbmk.pack --date="$TARGET" || exit 3
open ../sjdb-build/sjdb-"$(printf '%s' "$TARGET" | tr -d '-')".html
read -p "Is this bulletin OK to send? [y/N] " res
if [ "$res" = "y" ]
then
printf 'Running sendmail.py\n' >&2
python3 -m sjdbmk.sendmail --date="$TARGET" || exit 4
else
printf 'Not sending this bulletin. You may run sendmail manually instead:\npython3 -m sjdbmk.sendmail --date=%s\n' "$TARGET" >&2
fi