diff --git a/rowers/c2stuff.py b/rowers/c2stuff.py index 23bf374f..46cff86f 100644 --- a/rowers/c2stuff.py +++ b/rowers/c2stuff.py @@ -347,11 +347,33 @@ def get_token(code): prepped.body+="&scope=" prepped.body+=scope + print prepped.body + response = s.send(prepped) + with open("media/c2authorize.log","a") as f: + try: + f.write(reponse.status_code+"\n") + f.write(reponse.text+"\n") + f.write(response.json+"\n\n") + except: + pass + + token_json = response.json() - if token_json['status_code'] == 200: + try: + status_code = response.status_code + # status_code = token_json['status_code'] + except AttributeError: + # except KeyError: + return (0,response.text) + try: + status_code = token_json.status_code + except AttributeError: + return (0,'Attribute Error on c2_get_token') + + if status_code == 200: thetoken = token_json['access_token'] expires_in = token_json['expires_in'] refresh_token = token_json['refresh_token'] @@ -368,9 +390,9 @@ def make_authorization_url(request): state = str(uuid4()) scope = "user:read,results:write" - params = {"client_id": CLIENT_ID, + params = {"client_id": C2_CLIENT_ID, "response_type": "code", - "redirect_uri": REDIRECT_URI} + "redirect_uri": C2_REDIRECT_URI} url = "https://log.concept2.com/oauth/authorize?"+ urllib.urlencode(params) url += "&scope="+scope diff --git a/rowers/dataprep.py b/rowers/dataprep.py index 33827e10..e2edae21 100644 --- a/rowers/dataprep.py +++ b/rowers/dataprep.py @@ -466,6 +466,11 @@ def new_workout_from_file(r,f2, message = "This C2 logbook summary does not contain stroke data. Please download the Export Stroke Data file from the workout details on the C2 logbook." return (0,message,f2) + if fileformat == 'nostrokes': + os.remove(f2) + message = "It looks like this file doesn't contain stroke data." + return (0,message,f2) + # Some people try to upload RowPro summary logs if fileformat == 'rowprolog': os.remove(f2)