def convert(self): cur = self.db.urls.find({'link_type': 2}) for row in cur: if not os.path.exists(row['long_url']): continue filename = os.path.basename(row["info"]["title"]) print '%s: thumbnailing %s' % (row['short_code'], filename) with open(row["long_url"], "r") as fh: uf = UploadedFile( None, stream=fh, mimetype=row["mime_type"], filename=filename) uf._update_filenames() if os.path.exists(uf.thumb_filename) and \ os.path.exists(uf.tiny_thumb_filename): print '\tskipping existing thumb' continue uf._create_thumbnail()