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