Each semester, some 70 students enroll in Colby College's CS 151. A student worker is tasked with collating each week's projects into a sensible directory structure, including each student's writeup rendered as a PDF.
I'm lazy, so I wrote a program to automate this procedure.
Working off a project number and a list of students, LazyCollate locates the students' code on a network share and renders Confluence pages using either QtWebKit or PhantomJS. File renaming, content warnings, and web scraping are all done automatically.
LazyCollate is tested on a GNU/Linux system, but should be cross-platform.
The versions within your operating system's package manager will most likely be fine.
- Python 2.7
mechanize
(tested on 2.5)wkhtmltopdf
(tested on 0.9.9)- BeautifulSoup (version 3 or 4 okay)
-
Mount the CS 151 network share to
/mnt/CS151
(or elsewhere, but changeCS151_MOUNT_POINT
incollate.py
if you do so). -
Optionally change any of the global variables within
collate.py
.
First, create a file students.txt
with each CS151 student's Colby ID on its
own line.
Then, to collate project 2, call:
$ python collate.py 2 students.txt
LazyCollate will ask for your password and log in for you. Then, sit back while it does the rest!
LazyCollate writes out to the comprehensive collation.log
. The --verbose
flag will ensure that all messages permeate to standard output in addition to
this log file.
To see all available options:
$ python collate.py --help
LazyCollate is designed to work with Atlassian Confluence 3.5.13's login
system. If failed login error messages change, or if the HTML login form changes
name or field names, writeups.py
will need to be modified accordingly.
Cookie-based logins with wkhtmltopdf
don't work currently. The active workaround
is to just POST
the username and password with a redirect for the desired
page (such as in save_writeup()
in collate.py
). See cookie_login()
in
writeups.py
for where cookies should work.
wkhtmltopdf
has an issue on OS X with printing Conflence URL's with a POST
(passing a recommended flag might help, but it's far easier to just use
phantomjs
instead).