|
@@ -48,11 +48,9 @@ class MediaPath(): |
|
|
def get_list(self, media_table, linked_id): |
|
|
def get_list(self, media_table, linked_id): |
|
|
filelist = list() |
|
|
filelist = list() |
|
|
curpath = self.get_mediapath(media_table, linked_id, None) |
|
|
curpath = self.get_mediapath(media_table, linked_id, None) |
|
|
print curpath |
|
|
|
|
|
if not os.path.isdir(curpath): |
|
|
if not os.path.isdir(curpath): |
|
|
return list() |
|
|
return list() |
|
|
for f in os.listdir(curpath): |
|
|
for f in os.listdir(curpath): |
|
|
print curpath |
|
|
|
|
|
if os.path.isdir(os.path.join(curpath,f)): |
|
|
if os.path.isdir(os.path.join(curpath,f)): |
|
|
continue |
|
|
continue |
|
|
if f.endswith('.type'): |
|
|
if f.endswith('.type'): |
|
@@ -69,7 +67,6 @@ class MediaPath(): |
|
|
if not os.path.isdir(curpath): |
|
|
if not os.path.isdir(curpath): |
|
|
return list() |
|
|
return list() |
|
|
for f in os.listdir(curpath): |
|
|
for f in os.listdir(curpath): |
|
|
print curpath |
|
|
|
|
|
if os.path.isdir(os.path.join(curpath,f)): |
|
|
if os.path.isdir(os.path.join(curpath,f)): |
|
|
continue |
|
|
continue |
|
|
if f.endswith('.type'): |
|
|
if f.endswith('.type'): |
|
@@ -154,9 +151,7 @@ class MediaUpload(MediaPath): |
|
|
result['error'] = 'Ce type fichier n\'est malheureusement pas supporté. ' |
|
|
result['error'] = 'Ce type fichier n\'est malheureusement pas supporté. ' |
|
|
result['error'] += 'Les fichiers acceptées sont les images et pdf.' |
|
|
result['error'] += 'Les fichiers acceptées sont les images et pdf.' |
|
|
return False |
|
|
return False |
|
|
print result['size'] |
|
|
|
|
|
if result['size'] < MIN_FILE_SIZE: |
|
|
if result['size'] < MIN_FILE_SIZE: |
|
|
raise |
|
|
|
|
|
result['error'] = 'le fichier est trop petit' |
|
|
result['error'] = 'le fichier est trop petit' |
|
|
elif result['size'] > MAX_FILE_SIZE: |
|
|
elif result['size'] > MAX_FILE_SIZE: |
|
|
result['error'] = 'le fichier est trop voluminueux' |
|
|
result['error'] = 'le fichier est trop voluminueux' |
|
@@ -254,7 +249,6 @@ class MediaUpload(MediaPath): |
|
|
def fileinfo(self,name): |
|
|
def fileinfo(self,name): |
|
|
filename = self.mediapath(name) |
|
|
filename = self.mediapath(name) |
|
|
f, ext = os.path.splitext(name) |
|
|
f, ext = os.path.splitext(name) |
|
|
print "fileinfo ? '%s'" % name, filename |
|
|
|
|
|
if ext!='.type' and os.path.isfile(filename): |
|
|
if ext!='.type' and os.path.isfile(filename): |
|
|
info = {} |
|
|
info = {} |
|
|
info['name'] = name |
|
|
info['name'] = name |
|
@@ -318,21 +312,18 @@ class MediaUpload(MediaPath): |
|
|
except IOError: |
|
|
except IOError: |
|
|
pass |
|
|
pass |
|
|
except OSError: |
|
|
except OSError: |
|
|
print self.mediapath(filename) + '.type', 'Not found' |
|
|
|
|
|
pass |
|
|
pass |
|
|
try: |
|
|
try: |
|
|
os.remove(self.thumbnailpath(filename)) |
|
|
os.remove(self.thumbnailpath(filename)) |
|
|
except IOError: |
|
|
except IOError: |
|
|
pass |
|
|
pass |
|
|
except OSError: |
|
|
|
|
|
print self.thumbnailpath(filename), 'Not found' |
|
|
|
|
|
|
|
|
except OSError: |
|
|
pass |
|
|
pass |
|
|
try: |
|
|
try: |
|
|
os.remove(self.thumbnailpath(filename+".jpg")) |
|
|
os.remove(self.thumbnailpath(filename+".jpg")) |
|
|
except IOError: |
|
|
except IOError: |
|
|
pass |
|
|
pass |
|
|
except OSError: |
|
|
|
|
|
print self.thumbnailpath(filename), 'Not found' |
|
|
|
|
|
|
|
|
except OSError: |
|
|
pass |
|
|
pass |
|
|
try: |
|
|
try: |
|
|
os.remove(self.mediapath(filename)) |
|
|
os.remove(self.mediapath(filename)) |
|
|