more code for garmin files
This commit is contained in:
@@ -110,14 +110,18 @@ def garmin_open(user):
|
|||||||
|
|
||||||
return token
|
return token
|
||||||
|
|
||||||
def get_garmin_file(r,callbackURL,starttime):
|
def get_garmin_file(r,callbackURL,starttime,fileType):
|
||||||
garmin = OAuth1Session(oauth_data['client_id'],
|
job = queuehigh.enqueue(
|
||||||
client_secret=oauth_data['client_secret'],
|
get_garmin_file,
|
||||||
resource_owner_key=r.garmintoken,
|
oauth_data['client_id'],
|
||||||
resource_owner_secret=r.garminrefreshtoken,
|
oauth_data['client_secret'],
|
||||||
|
garmintoken,
|
||||||
|
garminrefreshtoken,
|
||||||
|
r.user.id,
|
||||||
|
callbackURL,filetype
|
||||||
)
|
)
|
||||||
response = garmin.get(callbackURL)
|
|
||||||
return 1
|
return job.id
|
||||||
|
|
||||||
def get_garmin_workout_list(user):
|
def get_garmin_workout_list(user):
|
||||||
r = Rower.objects.get(user=user)
|
r = Rower.objects.get(user=user)
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ from rowsandall_app.settings_dev import SITE_URL as SITE_URL_DEV
|
|||||||
from rowsandall_app.settings import PROGRESS_CACHE_SECRET
|
from rowsandall_app.settings import PROGRESS_CACHE_SECRET
|
||||||
from rowsandall_app.settings import SETTINGS_NAME
|
from rowsandall_app.settings import SETTINGS_NAME
|
||||||
from rowsandall_app.settings import workoutemailbox
|
from rowsandall_app.settings import workoutemailbox
|
||||||
|
from rowsandall_app.settings import UPLOAD_SERVICE_SECRET, UPLOAD_SERVICE_URL
|
||||||
|
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
@@ -678,6 +680,36 @@ def handle_getagegrouprecords(self,
|
|||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
@app.task(bind=True)
|
||||||
|
def get_garmin_file(client_id,client_secret,garmintoken,garminrefreshtoken,userid,url,filetype):
|
||||||
|
garmin = OAuth1Session(client_id,
|
||||||
|
client_secret=client_secret,
|
||||||
|
resource_owner_key=garmintoken,
|
||||||
|
resource_owner_secret=garminrefreshtoken,
|
||||||
|
)
|
||||||
|
|
||||||
|
filename = 'media/{code}_{id}.'.format(
|
||||||
|
code = uuid4().hex[:16],
|
||||||
|
id = userid
|
||||||
|
)+filetype
|
||||||
|
|
||||||
|
response = garmin.get(url, stream=True)
|
||||||
|
if response.status_code == 200:
|
||||||
|
with open(filename, 'wb') as out_file:
|
||||||
|
shutil.copyfileobj(response.raw, out_file)
|
||||||
|
|
||||||
|
uploadoptions = {
|
||||||
|
'secret':UPLOAD_SERVICE_SECRET,
|
||||||
|
'user':userid,
|
||||||
|
'file': filename,
|
||||||
|
'title': 'Import from Garmin File'
|
||||||
|
}
|
||||||
|
|
||||||
|
response = requests.post(UPLOAD_SERVICE_URL,data=uploadoptions)
|
||||||
|
|
||||||
|
del response
|
||||||
|
|
||||||
|
return 1
|
||||||
|
|
||||||
@app.task(bind=True)
|
@app.task(bind=True)
|
||||||
def long_test_task(self,aantal,debug=False,job=None,session_key=None):
|
def long_test_task(self,aantal,debug=False,job=None,session_key=None):
|
||||||
|
|||||||
@@ -34,12 +34,10 @@
|
|||||||
alt="connect with Polar" width="130"></a></p>
|
alt="connect with Polar" width="130"></a></p>
|
||||||
<p><a href="/rowers/me/tpauthorize/"><img src="/static/img/TP_logo_horz_2_color.png"
|
<p><a href="/rowers/me/tpauthorize/"><img src="/static/img/TP_logo_horz_2_color.png"
|
||||||
alt="connect with Polar" width="130"></a></p>
|
alt="connect with Polar" width="130"></a></p>
|
||||||
<!--
|
|
||||||
<p><a href="/rowers/me/garminauthorize"><img src="/static/img/garmin_badge_130.png"
|
<p><a href="/rowers/me/garminauthorize"><img src="/static/img/garmin_badge_130.png"
|
||||||
alt="connect with Garmin" with="130"></a></p>
|
alt="connect with Garmin" with="130"></a></p>
|
||||||
|
|
||||||
-->
|
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user