Created
May 31, 2013 23:09
-
-
Save cooncesean/5688543 to your computer and use it in GitHub Desktop.
This is a quick stab at fixing the old photo urls (currently pointing to turn) and repointing them to the new bucket..... Feel free to comment/fork/whatever..... don't run this without checking with @honza or Prague (and maybe testing on a staging env first).... we prolly need to deal with Formatted Photos as well.
This file contains 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
from ella.photos.models import Photo, redis, REDIS_PHOTO_KEY | |
OLD_BASE_URL = 'http://production-media.turn.com' | |
NEW_BASE_URL = 'http://production-media.purpleclover.com' | |
for p in Photo.objects.all().order_by('id'): | |
print 'p', p.id, p | |
# Get the photo hash from redis | |
photo_key = REDIS_PHOTO_KEY % photo_id | |
photo_hash = redis.hgetall(photo_key) | |
photo_url = photo_hash.get('url', None) | |
# Specifically check the `url` key | |
if photo_url: | |
# Replace the old url w/ the new one | |
photo_url = photo_url.replace(OLD_BASE_URL, NEW_BASE_URL) | |
# Update the redis hash | |
redis.hset(photo_key, 'url', photo_url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment