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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import _mysql | |
import sys | |
try: | |
con = _mysql.connect('localhost', 'testuser', '123456', 'testdb') | |
con.query('select version()') |
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
from django.core.files.uploadedfile import InMemoryUploadedFile | |
import StringIO | |
def MakeThumbnail(file): | |
img = Image.open(file) | |
img.thumbnail((128, 128), Image.ANTIALIAS) | |
thumbnailString = StringIO.StringIO() | |
img.save(thumbnailString, 'JPEG') | |
newFile = InMemoryUploadedFile(thumbnailString, None, 'temp.jpg', 'image/jpeg', thumbnailString.len, None) | |
return newFile |
NewerOlder