aboutsummaryrefslogtreecommitdiffstats
path: root/jm2l/upload.py
diff options
context:
space:
mode:
Diffstat (limited to 'jm2l/upload.py')
-rw-r--r--jm2l/upload.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/jm2l/upload.py b/jm2l/upload.py
index 029862f..c4a8534 100644
--- a/jm2l/upload.py
+++ b/jm2l/upload.py
@@ -9,7 +9,7 @@ from os import path
import mimetypes
import magic
import subprocess
-import cStringIO as StringIO
+from io import StringIO
# Database access imports
from .models import User, Place, Tiers, Event
@@ -136,7 +136,7 @@ class MediaUpload(MediaPath):
def validate(self, result, filecontent):
# let's say we don't trust the uploader
- RealMime = magic.from_buffer( filecontent.read(1024), mime=True)
+ RealMime = magic.from_buffer( filecontent.read(1024), mime=True).decode('utf-8')
filecontent.seek(0)
if RealMime!=result['type']:
result['error'] = 'l\'extension du fichier ne correspond pas à son contenu - '
@@ -182,7 +182,7 @@ class MediaUpload(MediaPath):
timage = Image.new('RGBA', (THUMBNAIL_SIZE, THUMBNAIL_SIZE), (255, 255, 255, 0))
timage.paste(
image,
- ((THUMBNAIL_SIZE - image.size[0]) / 2, (THUMBNAIL_SIZE - image.size[1]) / 2))
+ ((THUMBNAIL_SIZE - image.size[0]) // 2, (THUMBNAIL_SIZE - image.size[1]) // 2))
TargetFileName = self.thumbnailpath(filename)
timage.save( TargetFileName )
return self.thumbnailurl( os.path.basename(TargetFileName) )
@@ -199,7 +199,7 @@ class MediaUpload(MediaPath):
# Add thumbnail
timage.paste(
image,
- ((THUMBNAIL_SIZE - image.size[0]) / 2, (THUMBNAIL_SIZE - image.size[1]) / 2))
+ ((THUMBNAIL_SIZE - image.size[0]) // 2, (THUMBNAIL_SIZE - image.size[1]) // 2))
# Stamp with PDF file type
timage.paste(
pdf_indicator,
@@ -227,13 +227,13 @@ class MediaUpload(MediaPath):
('Impress','odp'),
('Calc','ods'),
('Draw','odg')]
- stampfilename = filter(lambda (x,y): ext.endswith(y), istamp)
+ stampfilename = filter(lambda x,y : ext.endswith(y), istamp)
stamp = Image.open( "jm2l/static/img/%s-icon.png" % stampfilename[0][0])
timage = Image.new('RGBA', (THUMBNAIL_SIZE, THUMBNAIL_SIZE), (255, 255, 255, 0))
# Add thumbnail
timage.paste(
image,
- ((THUMBNAIL_SIZE - image.size[0]) / 2, (THUMBNAIL_SIZE - image.size[1]) / 2))
+ ((THUMBNAIL_SIZE - image.size[0]) // 2, (THUMBNAIL_SIZE - image.size[1]) // 2))
# Stamp with PDF file type
timage.paste(
stamp,
@@ -334,7 +334,7 @@ class MediaUpload(MediaPath):
return self.delete()
results = []
for name, fieldStorage in self.request.POST.items():
- if isinstance(fieldStorage,unicode):
+ if isinstance(fieldStorage,str): # FIXME
continue
result = {}
result['name'] = os.path.basename(fieldStorage.filename)