added better user opening
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,6 +3,7 @@
|
|||||||
testcert.crt
|
testcert.crt
|
||||||
testcert.key
|
testcert.key
|
||||||
garminlog.log
|
garminlog.log
|
||||||
|
strava_webhooks.log
|
||||||
|
|
||||||
# Compiled python modules.
|
# Compiled python modules.
|
||||||
*.pyc
|
*.pyc
|
||||||
|
|||||||
@@ -326,6 +326,7 @@ def create_async_workout(alldata,user,stravaid,debug=False):
|
|||||||
from rowers.utils import get_strava_stream
|
from rowers.utils import get_strava_stream
|
||||||
|
|
||||||
def async_get_workout(user,stravaid):
|
def async_get_workout(user,stravaid):
|
||||||
|
token = strava_open(user)
|
||||||
csvfilename = 'media/{code}_{stravaid}.csv'.format(code=uuid4().hex[:16],stravaid=stravaid)
|
csvfilename = 'media/{code}_{stravaid}.csv'.format(code=uuid4().hex[:16],stravaid=stravaid)
|
||||||
job = myqueue(queue,
|
job = myqueue(queue,
|
||||||
fetch_strava_workout,
|
fetch_strava_workout,
|
||||||
|
|||||||
@@ -2721,6 +2721,10 @@ def fetch_strava_workout(stravatoken,oauth_data,stravaid,csvfilename,userid,debu
|
|||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'resolution': 'medium',}
|
'resolution': 'medium',}
|
||||||
url = "https://www.strava.com/api/v3/activities/"+str(stravaid)
|
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())
|
||||||
|
return 0
|
||||||
workoutsummary = requests.get(url,headers=headers).json()
|
workoutsummary = requests.get(url,headers=headers).json()
|
||||||
try:
|
try:
|
||||||
startdatetime = workoutsummary['start_date']
|
startdatetime = workoutsummary['start_date']
|
||||||
@@ -2738,7 +2742,10 @@ def fetch_strava_workout(stravatoken,oauth_data,stravaid,csvfilename,userid,debu
|
|||||||
if t is not None:
|
if t is not None:
|
||||||
nr_rows = len(t)
|
nr_rows = len(t)
|
||||||
else:
|
else:
|
||||||
duration = int(workoutsummary['elapsed_time'])
|
try:
|
||||||
|
duration = int(workoutsummary['elapsed_time'])
|
||||||
|
except KeyError:
|
||||||
|
duration = 0
|
||||||
t = pd.Series(range(duration+1))
|
t = pd.Series(range(duration+1))
|
||||||
|
|
||||||
nr_rows = len(t)
|
nr_rows = len(t)
|
||||||
|
|||||||
Reference in New Issue
Block a user