Skip to content
This repository has been archived by the owner on Jun 22, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2209 from ryanlovett/update-course-fetch
Browse files Browse the repository at this point in the history
Extract course profiles from new hub location.
  • Loading branch information
ryanlovett authored Feb 9, 2021
2 parents 232d6be + 46c4c5d commit 3365a41
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
5 changes: 3 additions & 2 deletions images/fetch-course-emails/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:19.04
FROM ubuntu:20.04

RUN apt-get update && \
apt-get install -y --no-install-recommends \
Expand All @@ -15,5 +15,6 @@ ADD requirements.txt /tmp/requirements.txt
RUN pip3 install --no-cache-dir -r /tmp/requirements.txt

ADD course-emails.py /usr/local/bin/
ADD save-course-emails.sh /usr/local/bin/

CMD ["/usr/local/bin/course-emails.py", "-v"]
CMD ["/usr/local/bin/save-course-emails.sh"]
5 changes: 3 additions & 2 deletions images/fetch-course-emails/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
aiohttp==3.5.4
ruamel.yaml==0.16.0
aiohttp==3.7.3
ruamel.yaml==0.16.12
yq==2.12.0
git+https://github.com/ryanlovett/sis-cli.git@1635650
git+https://github.com/ryanlovett/ucbhr.git@48975fb
42 changes: 42 additions & 0 deletions images/fetch-course-emails/save-course-emails.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

# set -e

# all hub configuration
config_values="/etc/jupyterhub/config/values.yaml"

# output location
profile_dir="/srv/jupyterhub/profiles.d"

course_emails="/usr/local/bin/course-emails.py"

# space 24 hours apart; TODO: guessing k8s can loop this for us somehow
sleep_time=86400

while true ; do

if [ ! -f $custom_profiles ]; then
echo "No such file: $custom_profiles"
else

if [ ! -d $profile_dir ]; then mkdir -p $profile_dir ; fi

profiles=`cat ${config_values} | yq .custom.profiles | jq -r 'keys[]'`
echo profiles: ${profiles}

# write out email lists for each profile
for profile in ${profiles} ; do
for people in students instructors ; do
filename="${profile_dir}/${profile}-${people}.txt"
# write to tempfile because gathering addresses takes time
# and we don't want the hub to read an abbreviated list
outfile=`mktemp`
echo $profile $people $outfile
$course_emails $profile $people > $outfile
if [ -f $outfile ]; then mv $outfile $filename ; fi
done
done
fi

sleep $sleep_time
done

0 comments on commit 3365a41

Please sign in to comment.