Merge branch 'release/v18.1.13'
This commit is contained in:
@@ -244,7 +244,7 @@ polarcollection = (
|
|||||||
('InlineSkate','Skating'),
|
('InlineSkate','Skating'),
|
||||||
('Kayaking','Kayaking'),
|
('Kayaking','Kayaking'),
|
||||||
('Workout','Other Indoor'),
|
('Workout','Other Indoor'),
|
||||||
('other','Other Indoor'),
|
('other','Other'),
|
||||||
('Yoga','Yoga'),
|
('Yoga','Yoga'),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -322,7 +322,7 @@ stravamappinginv = {value:key for key,value in Reverse(stravacollection) if valu
|
|||||||
stmappinginv = {value:key for key,value in Reverse(stcollection) if value is not None}
|
stmappinginv = {value:key for key,value in Reverse(stcollection) if value is not None}
|
||||||
|
|
||||||
|
|
||||||
polarmappinginv = {value:key for key,value in Reverse(polarcollection) if value is not None}
|
polarmappinginv = {value.lower():key for key,value in Reverse(polarcollection) if value is not None}
|
||||||
|
|
||||||
garminmappinginv = {value:key for key, value in Reverse(garmincollection) if value is not None}
|
garminmappinginv = {value:key for key, value in Reverse(garmincollection) if value is not None}
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ from rowers.tasks import handle_request_post
|
|||||||
import rowers.dataprep as dataprep
|
import rowers.dataprep as dataprep
|
||||||
from rowers.dataprep import columndict
|
from rowers.dataprep import columndict
|
||||||
|
|
||||||
|
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
|
|
||||||
import stravalib
|
import stravalib
|
||||||
@@ -230,6 +231,7 @@ def get_polar_workouts(user):
|
|||||||
exercise_dict = response.json()
|
exercise_dict = response.json()
|
||||||
tcxuri = exerciseurl+'/tcx'
|
tcxuri = exerciseurl+'/tcx'
|
||||||
response = requests.get(tcxuri,headers=headers2)
|
response = requests.get(tcxuri,headers=headers2)
|
||||||
|
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
filename = 'media/mailbox_attachments/{code}_{id}.tcx'.format(
|
filename = 'media/mailbox_attachments/{code}_{id}.tcx'.format(
|
||||||
id = exercise_dict['id'],
|
id = exercise_dict['id'],
|
||||||
@@ -240,28 +242,54 @@ def get_polar_workouts(user):
|
|||||||
with open(filename,'wb') as fop:
|
with open(filename,'wb') as fop:
|
||||||
fop.write(response.content)
|
fop.write(response.content)
|
||||||
|
|
||||||
|
workouttype = 'water'
|
||||||
|
try:
|
||||||
|
workouttype = mytypes.polarmappinginv[exercise_dict['detailed-sport-info'].lower()]
|
||||||
|
except KeyError:
|
||||||
|
try:
|
||||||
|
workouttype = mytypes.polarmappinginv[exercise_dict['sport'].lower()]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
# post file to upload api
|
# post file to upload api
|
||||||
# TODO: add workouttype
|
# TODO: add workouttype
|
||||||
uploadoptions = {
|
uploadoptions = {
|
||||||
'title':'',
|
'title':'',
|
||||||
'workouttype':'',
|
'workouttype':workouttype,
|
||||||
|
'boattype':'1x',
|
||||||
'user':user.id,
|
'user':user.id,
|
||||||
'secret':settings.UPLOAD_SERVICE_SECRET,
|
'secret':settings.UPLOAD_SERVICE_SECRET,
|
||||||
'file':filename,
|
'file':filename,
|
||||||
'title': '',
|
'title': '',
|
||||||
}
|
}
|
||||||
|
|
||||||
session = requests.session()
|
#session = requests.session()
|
||||||
newHeaders = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
#newHeaders = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
||||||
session.headers.update(newHeaders)
|
#session.headers.update(newHeaders)
|
||||||
|
|
||||||
url = settings.UPLOAD_SERVICE_URL
|
url = settings.UPLOAD_SERVICE_URL
|
||||||
|
|
||||||
dologging('polar.log',uploadoptions)
|
dologging('polar.log',uploadoptions)
|
||||||
dologging('polar.log',url)
|
dologging('polar.log',url)
|
||||||
response = session.post(url,json=uploadoptions)
|
#response = session.post(url,json=uploadoptions)
|
||||||
|
job = myqueue(
|
||||||
|
queuehigh,
|
||||||
|
handle_request_post,
|
||||||
|
url,
|
||||||
|
uploadoptions
|
||||||
|
)
|
||||||
|
|
||||||
dologging('polar.log',response.status_code)
|
dologging('polar.log',response.status_code)
|
||||||
|
if response.status_code != 200:
|
||||||
|
try:
|
||||||
|
dologging('polar.log',response.text)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
dologging('polar.log', response.json())
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
exercise_dict['filename'] = filename
|
exercise_dict['filename'] = filename
|
||||||
else:
|
else:
|
||||||
|
|||||||
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Normal file
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Normal file
Binary file not shown.
Reference in New Issue
Block a user