Created
October 16, 2014 17:14
-
-
Save shaneharter/b50a48530666f211cd56 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with make_temp_dir(listing_id) as tmpdir: | |
logger.console('Downloading assets for %s to %s' % (listing_id, tmpdir)) | |
photoset = photos.Photoset(filenames, tmpdir, limit=MAXIMUM_PHOTOS, subprocessor=logged_popen) | |
photoset.load() | |
if photoset.count() < MINIMUM_PHOTOS: | |
raise RuntimeWarning('Too few conforming photos') | |
photoset.process() | |
def make_temp_dir(listing_id): | |
""" A context manager for the temp directory to ensure we clean up after ourselves """ | |
temp_dir = tempfile.mkdtemp(prefix='%s.' % str(listing_id)) | |
try: | |
yield temp_dir | |
finally: | |
shutil.rmtree(temp_dir) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment