File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 11import copy
22import os
33import shutil
4+ import errno
45
56import PIL
67from PIL import Image
@@ -71,15 +72,20 @@ def placeholder_upload():
7172 wpercent = (basewidth / float (img .size [0 ]))
7273 hsize = int ((float (img .size [1 ]) * float (wpercent )))
7374 img = img .resize ((basewidth , hsize ), PIL .Image .ANTIALIAS )
74- os .mkdir (app .config ['TEMP_UPLOADS_FOLDER' ])
75+ try :
76+ os .mkdir (app .config ['TEMP_UPLOADS_FOLDER' ])
77+ except OSError as exc :
78+ if exc .errno != errno .EEXIST :
79+ raise exc
80+ pass
7581 img .save (app .config ['TEMP_UPLOADS_FOLDER' ] + '/temp.png' )
7682 file_name = temp_img_file .rsplit ('/' , 1 )[1 ]
7783 thumbnail_file = UploadedFile (file_path = temp_img_file , filename = file_name )
7884 background_thumbnail_url = upload (
7985 thumbnail_file ,
8086 'placeholders/thumbnail/' + filename
8187 )
82- shutil .rmtree (path = app .config ['TEMP_UPLOADS_FOLDER' ] + '/temp/' )
88+ shutil .rmtree (path = app .config ['TEMP_UPLOADS_FOLDER' ])
8389 placeholder_db = DataGetter .get_custom_placeholder_by_name (request .form ['name' ])
8490 if placeholder_db :
8591 placeholder_db .url = placeholder
You can’t perform that action at this time.
0 commit comments