fix errors tcx
This commit is contained in:
@@ -128,6 +128,8 @@ def send_template_email(from_email, to_email, subject,
|
||||
umsg.save()
|
||||
except User.DoesNotExist:
|
||||
pass
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
if not emailbounced:
|
||||
res = msg.send()
|
||||
|
||||
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Binary file not shown.
@@ -15,7 +15,7 @@ from datetime import datetime as dt
|
||||
|
||||
import rowingdata.tcxtools as tcxtools
|
||||
from rowingdata import TCXParser, rowingdata
|
||||
|
||||
import arrow
|
||||
|
||||
class XMLParser(BaseParser):
|
||||
media_type = "application/xml"
|
||||
@@ -239,12 +239,14 @@ def strokedata_tcx(request):
|
||||
Upload a TCX file through API
|
||||
"""
|
||||
if request.method != 'POST':
|
||||
dologging('apilog.log','GET request to TCX endpoint')
|
||||
return HttpResponseNotAllowed("Method not supported") # pragma: no cover
|
||||
|
||||
if request.content_type.lower() != 'application/xml':
|
||||
dologging('apilog.log','POST data not application/xml, request to TCX endpoint')
|
||||
return HttpResponseNotAllowed("Need application/xml")
|
||||
|
||||
dologging('apilog.log', request.user.username+" (strokedatajson_TCX POST)")
|
||||
dologging('apilog.log', request.user.username+" (strokedata_tcx POST)")
|
||||
|
||||
try:
|
||||
tcxdata = request.data
|
||||
@@ -267,10 +269,12 @@ def strokedata_tcx(request):
|
||||
total_duration += lap_duration_seconds
|
||||
|
||||
except Exception as e:
|
||||
dologgin('apilog.log','TCX')
|
||||
dologging('apilog.log',e)
|
||||
return HttpResponseNotAllowed("Could not parse TCX data")
|
||||
|
||||
|
||||
try:
|
||||
tcxfilename = 'media/{code}.tcx'.format(code=uuid4().hex[:16])
|
||||
xml_string = ET.tostring(tcxdata, encoding='utf-8', method='xml').decode('utf-8')
|
||||
|
||||
@@ -279,7 +283,8 @@ def strokedata_tcx(request):
|
||||
|
||||
|
||||
duration = totaltime_sec_to_string(total_duration)
|
||||
startdatetime = dt.strptime(start_time_str, "%Y-%m-%dT%H:%M:%S%z")
|
||||
startdatetime = arrow.get(start_time_str)
|
||||
#startdatetime = dt.strptime(start_time_str, "%Y-%m-%dT%H:%M:%S%z")
|
||||
startdate = startdatetime.date()
|
||||
partofday = part_of_day(startdatetime.hour)
|
||||
title = '{partofday} water'.format(partofday=partofday)
|
||||
@@ -317,6 +322,11 @@ def strokedata_tcx(request):
|
||||
"workout id": workoutid,
|
||||
"status": "success",
|
||||
})
|
||||
except Exception as e:
|
||||
dologging('apilog.log','TCX API endpoint')
|
||||
dologging('apilog.log',e)
|
||||
return HttpResponse(status=500)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user