CSV file emailing for gzipped
This commit is contained in:
@@ -2,6 +2,8 @@ from celery import Celery,app
|
||||
import os
|
||||
import time
|
||||
import gc
|
||||
import gzip
|
||||
import shutil
|
||||
|
||||
import rowingdata
|
||||
from rowingdata import main as rmain
|
||||
@@ -88,8 +90,16 @@ def handle_sendemailcsv(first_name,last_name,email,csvfile):
|
||||
[fullemail])
|
||||
|
||||
|
||||
email.attach_file(csvfile)
|
||||
|
||||
if os.path.isfile(csvfile):
|
||||
email.attach_file(csvfile)
|
||||
else:
|
||||
csvfile2 = csvfile[:-3]
|
||||
with gzip.open(csvfile,'rb') as f_in, open(csvfile2,'wb') as f_out:
|
||||
shutil.copyfileobj(f_in, f_out)
|
||||
|
||||
email.attach_file(csvfile2)
|
||||
os.remove(csvfile2)
|
||||
|
||||
res = email.send()
|
||||
|
||||
return 1
|
||||
|
||||
Reference in New Issue
Block a user