From 5ddc463d6e6f4ace91fc59570371c13c2176b671 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Sat, 25 Feb 2017 19:41:25 +0100 Subject: [PATCH 01/10] nothing --- rowers/c2stuff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rowers/c2stuff.py b/rowers/c2stuff.py index 23bf374f..2d4c8524 100644 --- a/rowers/c2stuff.py +++ b/rowers/c2stuff.py @@ -350,7 +350,7 @@ def get_token(code): response = s.send(prepped) token_json = response.json() - + if token_json['status_code'] == 200: thetoken = token_json['access_token'] expires_in = token_json['expires_in'] From 00634aba7c1b11c8e04a86326a3ebdb8285c5749 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Sat, 25 Feb 2017 19:46:00 +0100 Subject: [PATCH 02/10] nothing --- rowers/c2stuff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rowers/c2stuff.py b/rowers/c2stuff.py index 2d4c8524..23bf374f 100644 --- a/rowers/c2stuff.py +++ b/rowers/c2stuff.py @@ -350,7 +350,7 @@ def get_token(code): response = s.send(prepped) token_json = response.json() - + if token_json['status_code'] == 200: thetoken = token_json['access_token'] expires_in = token_json['expires_in'] From a4b98ed852afda8213c7f44578803ebb406ff444 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Sat, 25 Feb 2017 19:50:51 +0100 Subject: [PATCH 03/10] more fancy error catching in c2stuff --- rowers/c2stuff.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rowers/c2stuff.py b/rowers/c2stuff.py index 23bf374f..676c724d 100644 --- a/rowers/c2stuff.py +++ b/rowers/c2stuff.py @@ -351,7 +351,12 @@ def get_token(code): token_json = response.json() - if token_json['status_code'] == 200: + try: + status_code = token_json['status_code'] + except KeyError: + status_code = token_json.status_code + + if status_code == 200: thetoken = token_json['access_token'] expires_in = token_json['expires_in'] refresh_token = token_json['refresh_token'] From 7d4d0c08a8d848cf2d5696a9bd4867352c7d6a43 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Sat, 25 Feb 2017 20:01:37 +0100 Subject: [PATCH 04/10] catching attributeerror --- rowers/c2stuff.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rowers/c2stuff.py b/rowers/c2stuff.py index 676c724d..804df73c 100644 --- a/rowers/c2stuff.py +++ b/rowers/c2stuff.py @@ -354,7 +354,10 @@ def get_token(code): try: status_code = token_json['status_code'] except KeyError: - status_code = token_json.status_code + 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'] From 333fd7f98a8b0b85592f484b5de42c23db1d8569 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Sun, 26 Feb 2017 19:27:53 +0100 Subject: [PATCH 05/10] v1.25 --- rowers/c2stuff.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rowers/c2stuff.py b/rowers/c2stuff.py index 804df73c..965b2c2d 100644 --- a/rowers/c2stuff.py +++ b/rowers/c2stuff.py @@ -347,8 +347,14 @@ def get_token(code): prepped.body+="&scope=" prepped.body+=scope + print prepped.body + response = s.send(prepped) + print response.body + print '' + print response.text + token_json = response.json() try: @@ -376,9 +382,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 From 15f91eff88eb27362903df31adabebd0198bd292 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Sun, 26 Feb 2017 19:45:55 +0100 Subject: [PATCH 06/10] write response to error file --- rowers/c2stuff.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/rowers/c2stuff.py b/rowers/c2stuff.py index 965b2c2d..e0d9ef29 100644 --- a/rowers/c2stuff.py +++ b/rowers/c2stuff.py @@ -351,9 +351,12 @@ def get_token(code): response = s.send(prepped) - print response.body - print '' - print response.text + with open("media/c2authorize.log","a") as f: + f.write(reponse+"\n") + f.write(reponse.status_code+"\n") + f.write(reponse.text+"\n") + f.write(response.json+"\n\n") + token_json = response.json() From 0e26631cb5bc219e17663843f408dd8d08e3fed5 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Sun, 26 Feb 2017 19:53:53 +0100 Subject: [PATCH 07/10] v1.27 --- rowers/c2stuff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rowers/c2stuff.py b/rowers/c2stuff.py index e0d9ef29..e5cdf5a2 100644 --- a/rowers/c2stuff.py +++ b/rowers/c2stuff.py @@ -352,7 +352,7 @@ def get_token(code): response = s.send(prepped) with open("media/c2authorize.log","a") as f: - f.write(reponse+"\n") + f.write(response+"\n") f.write(reponse.status_code+"\n") f.write(reponse.text+"\n") f.write(response.json+"\n\n") From db0eadc7c0b3f63c957b6136aced8efe00c5fe9d Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Sun, 26 Feb 2017 19:59:36 +0100 Subject: [PATCH 08/10] v1.28 --- rowers/c2stuff.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/rowers/c2stuff.py b/rowers/c2stuff.py index e5cdf5a2..5bc7afa7 100644 --- a/rowers/c2stuff.py +++ b/rowers/c2stuff.py @@ -352,10 +352,12 @@ def get_token(code): response = s.send(prepped) with open("media/c2authorize.log","a") as f: - f.write(response+"\n") - f.write(reponse.status_code+"\n") - f.write(reponse.text+"\n") - f.write(response.json+"\n\n") + try: + f.write(reponse.status_code+"\n") + f.write(reponse.text+"\n") + f.write(response.json+"\n\n") + except: + pass token_json = response.json() From afe3d132b5e0904341cc60591b4e8d599de13c1f Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Sun, 26 Feb 2017 20:08:16 +0100 Subject: [PATCH 09/10] v1.29 --- rowers/c2stuff.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rowers/c2stuff.py b/rowers/c2stuff.py index 5bc7afa7..46cff86f 100644 --- a/rowers/c2stuff.py +++ b/rowers/c2stuff.py @@ -363,8 +363,11 @@ def get_token(code): token_json = response.json() try: - status_code = token_json['status_code'] - except KeyError: + 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: From 59b4dc433305fcf656e66d5711e4e498012fb685 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Mon, 27 Feb 2017 14:11:55 +0100 Subject: [PATCH 10/10] added check for file length --- rowers/dataprep.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rowers/dataprep.py b/rowers/dataprep.py index 71e6d585..c2ea9fdf 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)