Merge branch 'release/v12.05'
This commit is contained in:
@@ -102,6 +102,7 @@ import requests
|
||||
import rowers.longtask as longtask
|
||||
import arrow
|
||||
import stravalib
|
||||
from stravalib.exc import ActivityUploadFailed
|
||||
|
||||
from rowers.utils import get_strava_stream
|
||||
|
||||
@@ -171,17 +172,22 @@ def handle_runkeeper_sync(workoutid,url,headers,data,debug=False,**kwargs):
|
||||
@app.task
|
||||
def handle_strava_sync(stravatoken,workoutid,filename,name,activity_type,description,debug=False,**kwargs):
|
||||
client = stravalib.Client(access_token=stravatoken)
|
||||
failed = False
|
||||
with open(filename,'rb') as f:
|
||||
act = client.upload_activity(f,'tcx.gz',name=name)
|
||||
res = act.wait(poll_interval=5.0, timeout=60)
|
||||
try:
|
||||
act = client.update_activity(res.id,activity_type=activity_type,
|
||||
description=description,device_name='Rowsandall.com')
|
||||
except TypeError:
|
||||
act = client.update_activity(res.id,activity_type=activity_type,
|
||||
description=description)
|
||||
try:
|
||||
res = act.wait(poll_interval=5.0, timeout=60)
|
||||
except ActivityUploadFailed:
|
||||
failed = True
|
||||
if not failed:
|
||||
try:
|
||||
act = client.update_activity(res.id,activity_type=activity_type,
|
||||
description=description,device_name='Rowsandall.com')
|
||||
except TypeError:
|
||||
act = client.update_activity(res.id,activity_type=activity_type,
|
||||
description=description)
|
||||
|
||||
result = update_workout_field_sql(workoutid,'uploadedtostrava',res.id,debug=debug)
|
||||
result = update_workout_field_sql(workoutid,'uploadedtostrava',res.id,debug=debug)
|
||||
try:
|
||||
os.remove(filename)
|
||||
except WindowsError:
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<th align="left">Unit</th><td>{{ ps.sessionunit }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left">Comment</th><td>{{ ps.comment|linebreaks }}</td>
|
||||
<th align="left">Comment</th><td>{{ ps.comment|linebreaks|urlshorten:"50" }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
{% endfor %}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
{% if key == attr %}
|
||||
<tr>
|
||||
{% if key == 'comment' %}
|
||||
<td><b>{{ value.0 }}</b></td><td class="wrapwords">{{ value.1|linebreaks }}</td>
|
||||
<td><b>{{ value.0 }}</b></td><td class="wrapwords">{{ value.1|linebreaks|urlshorten:"50" }}</td>
|
||||
{% else %}
|
||||
<td><b>{{ value.0 }}</b></td><td class="wrapwords">{{ value.1 }}</td>
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user