using v3 now
This commit is contained in:
@@ -5,6 +5,14 @@ from django_rq import job
|
||||
# All the functionality needed to connect to Runkeeper
|
||||
from rowers.imports import *
|
||||
from rowers.utils import dologging
|
||||
from rowers.tasks import check_tp_workout_id
|
||||
|
||||
import django_rq
|
||||
queue = django_rq.get_queue('default')
|
||||
queuelow = django_rq.get_queue('low')
|
||||
queuehigh = django_rq.get_queue('low')
|
||||
|
||||
from rowers.utils import myqueue
|
||||
|
||||
# Python
|
||||
import gzip
|
||||
@@ -150,17 +158,24 @@ def uploadactivity(access_token, filename, description='',
|
||||
"Data": base64.b64encode(data_gz.getvalue()).decode("ascii")
|
||||
}
|
||||
|
||||
resp = requests.post(tpapilocation+"/v2/file/synchronous",
|
||||
#resp = requests.post(tpapilocation+"/v2/file/synchronous",
|
||||
# data=json.dumps(data),
|
||||
# headers=headers, verify=False)
|
||||
|
||||
resp = requests.post(tpapilocation+"/v3/file",
|
||||
data=json.dumps(data),
|
||||
headers=headers, verify=False)
|
||||
|
||||
if resp.status_code != 200: # pragma: no cover
|
||||
print(resp.headers['Location'])
|
||||
|
||||
|
||||
if resp.status_code not in (200, 202): # pragma: no cover
|
||||
dologging('tp_export.log',resp.status_code)
|
||||
dologging('tp_export.log',resp.reason)
|
||||
dologging('tp_export.log',json.dumps(data))
|
||||
return 0, resp.reason, resp.status_code, headers
|
||||
else:
|
||||
return resp.json()[0]["Id"], "ok", 200, ""
|
||||
return 1, "ok", 200, resp.headers
|
||||
|
||||
return 0, 0, 0, 0 # pragma: no cover
|
||||
|
||||
@@ -197,6 +212,12 @@ def workout_tp_upload(user, w): # pragma: no cover
|
||||
tpid = res
|
||||
w.save()
|
||||
os.remove(tcxfile)
|
||||
|
||||
job = myqueue(queuelow,
|
||||
check_tp_workout_id,
|
||||
w,
|
||||
headers['Location'])
|
||||
|
||||
return 'Successfully synchronized to TrainingPeaks', tpid
|
||||
|
||||
else: # no tcxfile
|
||||
|
||||
Reference in New Issue
Block a user