Private
Public Access
1
0

further improvements

This commit is contained in:
Sander Roosendaal
2020-07-14 20:17:16 +02:00
parent 1a8010ad1b
commit 2f78d26d37
2 changed files with 20 additions and 16 deletions

View File

@@ -6,6 +6,7 @@ import os
PY3K = sys.version_info >= (3, 0)
import zipfile
from zipfile import BadZipFile
import re
import time
from time import strftime
@@ -240,18 +241,21 @@ class Command(BaseCommand):
attachment.delete()
for rower in rowers:
if 'zip' in extension:
zip_file = zipfile.ZipFile(attachment.document)
for id,filename in enumerate(zip_file.namelist()):
datafile = zip_file.extract(
filename, path='media/')
if id>0:
title = name+' ('+str(id+1)+')'
else:
title = name
workoutid = processattachment(
rower, datafile, title, uploadoptions,
testing=testing
)
try:
zip_file = zipfile.ZipFile(attachment.document)
for id,filename in enumerate(zip_file.namelist()):
datafile = zip_file.extract(
filename, path='media/')
if id>0:
title = name+' ('+str(id+1)+')'
else:
title = name
workoutid = processattachment(
rower, datafile, title, uploadoptions,
testing=testing
)
except BadZipFile:
pass
else:
# move attachment and make workout
@@ -296,9 +300,9 @@ class Command(BaseCommand):
message.delete()
# Strava
rowers = Rower.objects.filter(strava_auto_import=True)
for r in rowers:
stravastuff.get_strava_workouts(r)
#rowers = Rower.objects.filter(strava_auto_import=True)
#for r in rowers:
# stravastuff.get_strava_workouts(r)
self.stdout.write(self.style.SUCCESS(
'Successfully processed email attachments'))