Private
Public Access
1
0

more loggin on strava webhooks

This commit is contained in:
Sander Roosendaal
2020-07-16 13:20:52 +02:00
parent 926e03b784
commit 8dbe4ba7e5
2 changed files with 26 additions and 2 deletions

View File

@@ -714,6 +714,7 @@ def handle_get_garmin_file(client_id,
with open(filename, 'wb') as out_file:
shutil.copyfileobj(response.raw, out_file)
del response
uploadoptions = {
@@ -729,6 +730,7 @@ def handle_get_garmin_file(client_id,
session.headers.update(newHeaders)
response = session.post(UPLOAD_SERVICE_URL,json=uploadoptions)
return 1
@app.task(bind=True)
@@ -2723,7 +2725,14 @@ def fetch_strava_workout(stravatoken,oauth_data,stravaid,csvfilename,userid,debu
url = "https://www.strava.com/api/v3/activities/"+str(stravaid)
response = requests.get(url,headers=headers)
if response.status_code != 200:
print(response,response.json())
timestamp = time.strftime('%b-%d-%Y_%H%M', t)
with open('strava_webhooks.log','a') as f:
f.write('\n')
f.write(timestamp)
f.write(' ')
f.write('handle_get_garmin_file response code {code}\n'.format(code=response.status_code))
f.write('Response json {json}\n'.format(json=response.json()))
return 0
workoutsummary = requests.get(url,headers=headers).json()
try:
@@ -2955,7 +2964,13 @@ def fetch_strava_workout(stravatoken,oauth_data,stravaid,csvfilename,userid,debu
session.headers.update(newHeaders)
response = session.post(UPLOAD_SERVICE_URL,json=uploadoptions)
timestamp = time.strftime('%b-%d-%Y_%H%M', t)
with open('strava_webhooks.log','a') as f:
f.write('\n')
f.write(timestamp)
f.write(' ')
f.write('handle_get_garmin_file posted file with strava id {stravaid} user id {userid}\n'.format(
stravaid=stravaid,userid=userid))
return 1

View File

@@ -1071,6 +1071,15 @@ def strava_webhook_view(request):
ws = Workout.objects.filter(uploadedtostrava=stravaid)
if ws.count()==0:
job = stravastuff.async_get_workout(r.user,stravaid)
else:
timestamp = time.strftime('%b-%d-%Y_%H%M', t)
with open('strava_webhooks.log','a') as f:
f.write('\n')
f.write(timestamp)
f.write(' ')
f.write('Workouts already existing:\n ')
for w in ws:
f.write('{w} \n'.format(str(w)))
elif aspect_type == 'delete':
try:
stravaid = data['object_id']