-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend_status_email
executable file
·56 lines (43 loc) · 1.9 KB
/
send_status_email
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
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python3
import subprocess
import sys
from textwrap import dedent
from ocflib.misc.mail import send_mail
# TSV or space separated file of username \t # of unexcused absences
# e.g. abizer 2
DATA_FILE = sys.argv[1]
SUBJECT = '[UNIX SysAdmin Decal] Attendance and Lab Report'
FROM = 'decal@ocf.berkeley.edu'
CC = 'decal+attendance@ocf.berkeley.edu'
message = dedent('''
Hello {name},
This is a status update for your current standing in the course.
Our records indicate you have {absences} unexcused absences. As a reminder, more than two unexcused absences is
grounds for NPing the course. Note that this figure does not include the final survey, which will allow you to waive
one of the unexcused absences. You can find a link to the survey on Piazza.
Our records indicate that you have been checked off for the following labs:
{labs}
Please note that this does not include labs that you have submitted but are pending to be checked off by a facilitator.
As a reminder, you need to complete at least 8/10 labs to pass the course.
If you think there are any errors in the above report, please contact us ASAP so we can resolve the issue.
Reply to this email or make a post on Piazza to get in touch.
Best,
Unix SysAdmin DeCal staff
''').strip()
with open(DATA_FILE, 'r') as d:
for i in d.read().strip().split('\n'):
student, absences = i.split()
try:
labs = subprocess.check_output(['./checkoff', 'view', student]).decode('utf-8').strip()
except subprocess.CalledProcessError as e:
# This is mostly in case you fatfinger someone's username, it'll just skip it
print(e)
continue
email = '{}@ocf.berkeley.edu'.format(student)
send_mail(
email,
SUBJECT,
message.format(name=student, absences=absences, labs=labs),
cc=CC,
sender=FROM,
)