added multi file zip support
This commit is contained in:
@@ -166,6 +166,8 @@ def make_new_workout_from_email(rr,f2,name,cntr=0):
|
||||
except IOError:
|
||||
f2 = f2.name+'.gz'
|
||||
fileformat = get_file_type('media/'+f2)
|
||||
except AttributeError:
|
||||
fileformat = get_file_type('media/'+f2)
|
||||
|
||||
if len(fileformat)==3 and fileformat[0]=='zip':
|
||||
f_to_be_deleted = f2
|
||||
|
||||
@@ -47,7 +47,8 @@ class Command(BaseCommand):
|
||||
attachments = MessageAttachment.objects.all()
|
||||
cntr = 0
|
||||
for a in attachments:
|
||||
extension = a.document[-3:].lower()
|
||||
extension = a.document.name[-3:].lower()
|
||||
print "aap ",extension
|
||||
donotdelete = 0
|
||||
m = Message.objects.get(id=a.message_id)
|
||||
from_address = m.from_address[0]
|
||||
@@ -61,18 +62,16 @@ class Command(BaseCommand):
|
||||
if extension == 'zip':
|
||||
z = zipfile.ZipFile(a.document)
|
||||
for f in z.namelist():
|
||||
f2 = z.extract(f)
|
||||
f2 = z.extract(f,path='media/')
|
||||
try:
|
||||
wid = [
|
||||
make_new_workout_from_email(rr,f2,name)
|
||||
make_new_workout_from_email(rr,f2[6:],name)
|
||||
]
|
||||
res += wid
|
||||
link = 'http://rowsandall.com/rowers/workout/'+str(wid)+'/edit'
|
||||
dd = send_confirm(u,name,link)
|
||||
except:
|
||||
res += ['fail: '+f]
|
||||
donotdelete = 1
|
||||
os.remove(f2)
|
||||
pass
|
||||
else:
|
||||
# move attachment and make workout
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user