Skip to content

Commit a0a60bd

Browse files
committed
Merge pull request #1704 from learning-unlimited/old-poll-schedules
Ressurect old schedule printing script
2 parents ea4c2ec + 7c6833a commit a0a60bd

File tree

2 files changed

+47
-4
lines changed

2 files changed

+47
-4
lines changed

esp/esp/program/modules/handlers/programprintables.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -972,10 +972,10 @@ def get_student_schedules(request, students, prog, extra='', onsite=False):
972972
elif 'img_format' in request.GET:
973973
file_type = request.GET['img_format']
974974
else:
975-
file_type = 'pdf'
976-
977-
if onsite and file_type == 'pdf':
978-
file_type = 'png'
975+
if onsite:
976+
file_type = 'png'
977+
else:
978+
file_type = 'pdf'
979979

980980
from django.conf import settings
981981
context['PROJECT_ROOT'] = settings.PROJECT_ROOT.rstrip('/') + '/'

esp/useful_scripts/poll_schedules.sh

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
PROGRAM="Spark"
4+
INSTANCE="2015"
5+
6+
echo "What printer do you want to print to? (lpr printer name)"
7+
read PRINTERNAME
8+
9+
echo "Where are you? (ESP website printer name)"
10+
read LOCATION
11+
12+
echo "Please enter the onsite username and password for the ESP website:"
13+
echo -n "Username: "
14+
read USERNAME
15+
16+
echo -n "Password: "
17+
read -s PASSWORD
18+
echo
19+
20+
CURL_COOKIE_STORE="curl_cookies.txt"
21+
22+
echo "Logging in..."
23+
curl -c "${CURL_COOKIE_STORE}" "https://esp.mit.edu/admin/" >/dev/null 2>&1
24+
curl -b "${CURL_COOKIE_STORE}" -c "${CURL_COOKIE_STORE}" -d "username=${USERNAME}&password=${PASSWORD}&this_is_the_login_form=1" "https://esp.mit.edu/admin/" >/dev/null 2>&1
25+
echo "Logged in!"
26+
27+
while (true); do
28+
TMPFILE="`mktemp`"
29+
curl -b "${CURL_COOKIE_STORE}" "https://esp.mit.edu/onsite/${PROGRAM}/${INSTANCE}/printschedules/${LOCATION}?gen_img&img_format=pdf" -o "${TMPFILE}" 2>/dev/null
30+
31+
if [ -n "`cat "${TMPFILE}"`" ]; then
32+
lpr -P "${PRINTERNAME}" < "${TMPFILE}"
33+
echo -n "Printed! "
34+
date
35+
rm "${TMPFILE}"
36+
else
37+
echo -n "."
38+
rm "${TMPFILE}"
39+
sleep 2s
40+
fi
41+
done
42+
43+

0 commit comments

Comments
 (0)