edx/edx-certificates — pull request #31 by jrbl (2014-12-11 18:59:23+00:00)
Title: Bugfix: Avoid s3 upload redundancy

This should land only after #30 because it can't be manually tested without that, so it's based on top of that.

Bugfix: Avoid s3 upload redundancy

* If you run the previous version of create_pdfs with a long course list and s3 uploading turned on, you'll notice that the upload routine re-walks the working directory tree for every generated cert. This means that as we get further into the course list, we do more and more uploads per cert.
* This starts the tree walks from the temporary directories for the current cert specifically, which makes the number of uploads linear in the number of certs.
* Also, memoize s3 connections, rather than creating a connection for every upload.
* Also, layout fixes for readability.
* Also fixes cleanup routine to only delete the working directories and their contents, rather than their parent. This makes it safe to set TMP_GEN_DIR to, e.g., '/var/tmp/'.

@stvstnfrd I think you'll be happy to see this?