Private
Public Access
1
0

adding some logging

This commit is contained in:
Sander Roosendaal
2020-08-20 16:42:59 +02:00
parent aa973d8e74
commit 363ed9647c

View File

@@ -7,6 +7,8 @@ from __future__ import unicode_literals, absolute_import
# All the functionality needed to connect to Strava
from scipy import optimize
from scipy.signal import savgol_filter
import time
from time import strftime
from django_mailbox.models import Message,Mailbox,MessageAttachment
@@ -75,6 +77,19 @@ def get_token(code):
return imports_get_token(code, oauth_data)
def strava_open(user):
t = time.localtime()
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('Getting token for user ')
f.write(str(user.rower.id))
f.write(' token expiry ')
f.write(str(user.rower.stravatokenexpirydate))
f.write(' ')
f.write(json.dumps(oauth_data))
f.write('\n')
token = imports_open(user, oauth_data)
if user.rower.strava_owner_id == 0:
strava_owner_id = set_strava_athlete_id(user)
@@ -357,7 +372,7 @@ def async_get_workout(user,stravaid):
token = strava_open(user)
except NoTokenError:
return 0
csvfilename = 'media/{code}_{stravaid}.csv'.format(code=uuid4().hex[:16],stravaid=stravaid)
job = myqueue(queue,
fetch_strava_workout,