Private
Public Access
1
0

Merge branch 'release/v16.7.3'

This commit is contained in:
Sander Roosendaal
2021-11-09 22:05:32 +01:00
5 changed files with 28 additions and 10 deletions

View File

@@ -139,8 +139,11 @@ def get_polar_notifications():
available_data = []
if response.status_code == 200:
available_data = response.json()['available-user-data']
try:
if response.status_code == 200:
available_data = response.json()['available-user-data']
except AttributeError:
pass
return available_data

View File

@@ -45,6 +45,7 @@ except ImportError: # pragma: no cover
JSONDecodeError = ValueError
from rowers.imports import *
from rowers.utils import dologging
webhookverification = "kudos_to_rowing"
webhooklink = SITE_URL+'/rowers/strava/webhooks/'
@@ -501,6 +502,7 @@ def workout_strava_upload(user,w, quick=False,asynchron=True):
tcxfile,w.name,activity_type,
w.notes
)
dologging('strava_export_log.log','Exporting as {t}'.format(t=activity_type))
return "Asynchronous sync",-1
try:
tcxfile,tcxmesg = createstravaworkoutdata(w)

View File

@@ -341,6 +341,7 @@ def handle_strava_sync(stravatoken,workoutid,filename,name,activity_type,descrip
dologging('strava_fail.log','Strava upload failed for Workout {id}'.format(id=workoutid))
failed = True
except FileNotFoundError: # pragma: no cover
dologging('strava_fail.log','Strava upload failed for Workout {id}'.format(id=workoutid))
failed = True
if not failed:
@@ -348,21 +349,21 @@ def handle_strava_sync(stravatoken,workoutid,filename,name,activity_type,descrip
try:
act = client.update_activity(res.id,activity_type=activity_type,
description=description,device_name='Rowsandall.com')
dologging('stravalog.log','Updating activity {id} to {type}'.format(
dologging('strava_export_log.log','Updating activity {id} to {type}'.format(
id=workoutid,
type=activity_type
))
except TypeError: # pragma: no cover
act = client.update_activity(res.id,activity_type=activity_type,
description=description)
dologging('stravalog.log','Updating activity {id} to {type}'.format(
dologging('strava_export_log.log','Updating activity {id} to {type}'.format(
id=workoutid,
type=activity_type
))
except: # pragma: no cover
e = sys.exc_info()[0]
dologging('stravalog.log','Update activity failed with error {e} for {id} to {type}'.format(
dologging('strava_export_log.log','Update activity failed with error {e} for {id} to {type}'.format(
id=workoutid,
type=activity_type,
e=e
@@ -3168,7 +3169,7 @@ def df_from_summary(data):
distances = [0]
try:
spms = [splits[0]['stroke_rate']]
except (KeyError, TypeError): # pragma: no cover
except (KeyError, TypeError, IndexError): # pragma: no cover
spms = [0]
try:
hrs = [splits[0]['heart_rate']['average']]
@@ -3298,9 +3299,13 @@ def handle_c2_async_workout(alldata,userid,c2token,c2id,delaysec,defaulttimezone
strokedata = pd.DataFrame.from_dict(s.json()['data'])
res = make_cumvalues(0.1*strokedata['t'])
cum_time = res[0]
lapidx = res[1]
try:
res = make_cumvalues(0.1*strokedata['t'])
cum_time = res[0]
lapidx = res[1]
except KeyError:
dologging('debuglog.log','No time values in stroke data')
return 0
unixtime = cum_time+starttimeunix

View File

@@ -15,6 +15,7 @@ from rowers.tasks import (
from rowers.models import GraphImage
from rowers.rower_rules import ispromember
from rowers.utils import dologging
from PIL import Image
@@ -600,6 +601,13 @@ def do_sync(w,options, quick=False):
message,id = stravastuff.workout_strava_upload(
w.user.user,w,quick=quick,asynchron=True,
)
dologging(
'strava_export_log.log',
'exporting workout {id} as {type}'.format(
id=w.id,
type = w.workouttype,
)
)
except NoTokenError: # pragma: no cover
id = 0
message = "Please connect to Strava first"

View File

@@ -1537,7 +1537,7 @@ def workout_c2import_view(request,page=1,userid=0,message=""):
with open('c2blocked.json','r') as c2blocked:
jsondata = json.load(c2blocked)
parkedids = jsondata['ids']
except (FileNotFoundError,JSONDecodeError): # pragma: no cover
except: # pragma: no cover
pass
knownc2ids = uniqify(knownc2ids+tombstones+parkedids)