Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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