fixed strava import errors
This commit is contained in:
@@ -163,9 +163,12 @@ def get_strava_workout(user,stravaid):
|
||||
url = "https://www.strava.com/api/v3/activities/"+str(stravaid)+"/streams/latlng?resolution="+fetchresolution
|
||||
latlongjson = requests.get(url,headers=headers)
|
||||
|
||||
t = np.array(timejson.json()[0]['data'])
|
||||
d = np.array(distancejson.json()[0]['data'])
|
||||
nr_rows = len(t)
|
||||
try:
|
||||
t = np.array(timejson.json()[0]['data'])
|
||||
d = np.array(distancejson.json()[0]['data'])
|
||||
nr_rows = len(t)
|
||||
except KeyError:
|
||||
return (0,"something went wrong with the Strava import")
|
||||
|
||||
try:
|
||||
spm = np.array( spmjson.json()[1]['data'])
|
||||
|
||||
@@ -1164,7 +1164,16 @@ def rower_process_twittercallback(request):
|
||||
# Process Strava Callback
|
||||
@login_required()
|
||||
def rower_process_stravacallback(request):
|
||||
code = request.GET['code']
|
||||
try:
|
||||
code = request.GET['code']
|
||||
except MultiValueDictKeyError:
|
||||
try:
|
||||
message = request.GET['error']
|
||||
except MultiValueDictKeyError:
|
||||
message = "access error"
|
||||
|
||||
return imports_view(request,message=message)
|
||||
|
||||
res = stravastuff.get_token(code)
|
||||
|
||||
if res[0]:
|
||||
@@ -4394,6 +4403,10 @@ def workout_c2import_view(request,message=""):
|
||||
# Import a workout from Strava
|
||||
@login_required()
|
||||
def workout_getstravaworkout_view(request,stravaid):
|
||||
res = stravastuff.get_strava_workout(request.user,stravaid)
|
||||
if not res[0]:
|
||||
message = "Something went wrong in Strava import"
|
||||
return imports_view(request,message=message)
|
||||
|
||||
strokedata = res[1]
|
||||
data = res[0]
|
||||
|
||||
Reference in New Issue
Block a user