CSV file emailing for gzipped
This commit is contained in:
@@ -255,6 +255,10 @@ def auto_delete_file_on_delete(sender, instance, **kwargs):
|
||||
if instance.csvfilename:
|
||||
if os.path.isfile(instance.csvfilename):
|
||||
os.remove(instance.csvfilename)
|
||||
if instance.csvfilename+'.gz':
|
||||
if os.path.isfile(instance.csvfilename+'.gz'):
|
||||
os.remove(instance.csvfilename+'.gz')
|
||||
|
||||
|
||||
@receiver(models.signals.post_delete,sender=Workout)
|
||||
def auto_delete_strokedata_on_delete(sender, instance, **kwargs):
|
||||
|
||||
@@ -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