oauth_token_secret=secrets['TUMBLR_OAUTH_TOKEN_SECRET']) params = { "type": "photo", "caption": caption, "tags": app_config.TUMBLR_TAGS, "source": "http://%s%s" % (app_config.SERVERS[0], png_path) } try: tumblr_post = t.post('post', blog_url=app_config.TUMBLR_URL, params=params) tumblr_url = u"http://%s/%s" % (app_config.TUMBLR_URL, tumblr_post['id']) logger.info('200 %s reader(%s) (times in EST)' % (tumblr_url, name)) if app_config.ZAZZLE_ENABLE: zazzlify_png(png_path, tumblr_post['id'], name, location) return redirect(tumblr_url, code=301) except TumblpyError, e: logger.error('%s %s http://%s%s reader(%s) (times in EST)' % ( e.error_code, e.msg, app_config.SERVERS[0], svg_path, name)) context = {} context['title'] = 'Tumblr error' context['message'] = '%s\n%s' % (e.error_code, e.msg) return render_template('500.html', **context) return redirect('%s#posts' % tumblr_url, code=301)
import os import app_config from zazzle import zazzlify_png with open('data/review_plus.csv') as f: rows = list(csv.reader(f)) for i, row in enumerate(rows): svg_url, status, tumblr_url, name, location = row if not tumblr_url: continue tumblr_id = tumblr_url.split('/')[-1] svg_path = svg_url.replace('http://%s/' % app_config.SERVERS[0], '') png_path = svg_path.replace('svg', 'png') path, filename = os.path.split(png_path) zazzle_path = os.path.join(path, tumblr_id + '.png') print i, png_path print zazzle_path if os.path.exists('/var/www/' + zazzle_path): print 'Skipping' continue print zazzlify_png(png_path, tumblr_id, name, location)