Private
Public Access
1
0

bug fixes

This commit is contained in:
Sander Roosendaal
2021-08-11 18:30:47 +02:00
parent 26aae04f5a
commit 5c49559ad0
3 changed files with 25 additions and 16 deletions

View File

@@ -323,19 +323,20 @@ def handle_sporttracks_sync(workoutid,url,headers,data,debug=False,**kwargs):
def handle_strava_sync(stravatoken,workoutid,filename,name,activity_type,description,debug=False,**kwargs):
client = stravalib.Client(access_token=stravatoken)
failed = False
with open(filename,'rb') as f:
try:
act = client.upload_activity(f,'tcx.gz',name=name)
try:
with open(filename,'rb') as f:
try:
res = act.wait(poll_interval=1.0, timeout=60)
except stravalib.exc.ActivityUploadFailed: # pragma: no cover
act = client.upload_activity(f,'tcx.gz',name=name)
try:
res = act.wait(poll_interval=1.0, timeout=60)
except stravalib.exc.ActivityUploadFailed: # pragma: no cover
failed = True
except JSONDecodeError: # pragma: no cover
failed = True
except stravalib.exc.ObjectNotFound: # pragma: no cover
failed = True
except ActivityUploadFailed: # pragma: no cover
failed = True
except JSONDecodeError: # pragma: no cover
failed = True
except stravalib.exc.ObjectNotFound: # pragma: no cover
failed = True
except ActivityUploadFailed: # pragma: no cover
failed = True
except FileNotFoundError:
failed = True
@@ -3489,7 +3490,7 @@ def fetch_strava_workout(stravatoken,oauth_data,stravaid,csvfilename,userid,debu
'strokelength':strokelength,
})
except ValueError:
return 0
return 0
try:
workouttype = mytypes.stravamappinginv[workoutsummary['type']]

BIN
rowers/tests/testdata/testdata.tcx.gz vendored Normal file

Binary file not shown.

View File

@@ -862,8 +862,10 @@ def workout_rp3import_view(request,userid=0):
workouts_list = pd.json_normalize(res.json()['data']['workouts'])
rp3ids = workouts_list['id'].values
try:
rp3ids = workouts_list['id'].values
except KeyError:
rp3ids = []
knownrp3ids = uniqify([
w.uploadedtorp3 for w in Workout.objects.filter(user=r)
@@ -874,13 +876,19 @@ def workout_rp3import_view(request,userid=0):
workouts = []
for key,data in workouts_list.iterrows():
i = data['id']
try:
i = data['id']
except KeyError:
i = 0
if i in knownrp3ids: # pragma: no cover
nnn = ''
else:
nnn = 'NEW'
s = data['executed_at']
try:
s = data['executed_at']
except KeyError:
s = ''
keys = ['id','starttime','new']
values = [i,s,nnn]