Private
Public Access
1
0

Seems to work (golang routine to test)

This commit is contained in:
Sander Roosendaal
2020-07-08 22:04:27 +02:00
parent 30b9fac1d5
commit ea2af4830c
5 changed files with 37 additions and 14 deletions

View File

@@ -12,6 +12,7 @@ import shutil
import numpy as np
import re
import sys
import json
from scipy import optimize
from scipy.signal import savgol_filter
@@ -50,6 +51,7 @@ from rowsandall_app.settings import SETTINGS_NAME
from rowsandall_app.settings import workoutemailbox
from rowsandall_app.settings import UPLOAD_SERVICE_SECRET, UPLOAD_SERVICE_URL
from requests_oauthlib import OAuth1, OAuth1Session
import pandas as pd
@@ -680,8 +682,19 @@ def handle_getagegrouprecords(self,
return 1
@app.task(bind=True)
def get_garmin_file(client_id,client_secret,garmintoken,garminrefreshtoken,userid,url,filetype):
@app.task
def handle_get_garmin_file(client_id,
client_secret,
garmintoken,
garminrefreshtoken,
userid,
url,
filetype,
*args,
**kwargs):
garmin = OAuth1Session(client_id,
client_secret=client_secret,
resource_owner_key=garmintoken,
@@ -694,6 +707,7 @@ def get_garmin_file(client_id,client_secret,garmintoken,garminrefreshtoken,useri
)+filetype
response = garmin.get(url, stream=True)
print(response.status_code,filename)
if response.status_code == 200:
with open(filename, 'wb') as out_file:
shutil.copyfileobj(response.raw, out_file)
@@ -704,10 +718,14 @@ def get_garmin_file(client_id,client_secret,garmintoken,garminrefreshtoken,useri
'secret':UPLOAD_SERVICE_SECRET,
'user':userid,
'file': filename,
'title': 'Import from Garmin File'
'title': filename[6:],
'workouttype':'water',
'boattype':'1x',
}
response = requests.post(UPLOAD_SERVICE_URL,data=uploadoptions)
session = requests.session()
newHeaders = {'Content-type': 'application/json', 'Accept': 'text/plain'}
session.headers.update(newHeaders)
response = session.post(UPLOAD_SERVICE_URL,json=uploadoptions)
return 1