From 9ce7f24d36ea7af722d5c012ed70bd736e19e8b2 Mon Sep 17 00:00:00 2001 From: Collin Date: Fri, 11 Aug 2017 09:11:24 -0400 Subject: [PATCH] Fix setio download status code handling, imports, images, misc cleanup --- tapiriik/services/Setio/setio.py | 18 ++++++++---------- tapiriik/services/__init__.py | 2 ++ .../img/services/{Setio.png => setio.png} | Bin .../img/services/{Setio_l.png => setio_l.png} | Bin 4 files changed, 10 insertions(+), 10 deletions(-) rename tapiriik/web/static/img/services/{Setio.png => setio.png} (100%) rename tapiriik/web/static/img/services/{Setio_l.png => setio_l.png} (100%) diff --git a/tapiriik/services/Setio/setio.py b/tapiriik/services/Setio/setio.py index 463b44fb5..1753a1dd3 100644 --- a/tapiriik/services/Setio/setio.py +++ b/tapiriik/services/Setio/setio.py @@ -156,6 +156,7 @@ def DownloadActivityList(self, svcRecord, exhaustive=False): user_exception=UserException(UserExceptionType.Authorization, intervention_required=True)) + activity.Notes = None if streamdata.status_code == 200: # Ok try: commentdata = streamdata.json() @@ -164,10 +165,6 @@ def DownloadActivityList(self, svcRecord, exhaustive=False): if "comment" in commentdata: activity.Notes = commentdata["comment"] - else: - activity.Notes = None - else: - activity.Notes = None activity.GPS = True @@ -180,7 +177,6 @@ def DownloadActivityList(self, svcRecord, exhaustive=False): return activities, exclusions def DownloadActivity(self, svcRecord, activity): - activityID = activity.ServiceData["ActivityID"] extID = svcRecord.ExternalID url = self.SetioDomain + "getRunData" @@ -198,11 +194,13 @@ def DownloadActivity(self, svcRecord, activity): user_exception=UserException(UserExceptionType.Authorization, intervention_required=True)) - if streamdata.status_code == 200: # Ok - try: - streamdata = streamdata.json() - except: - raise APIException("Stream data returned is not JSON") + if streamdata.status_code != 200: + raise APIException("Unknown Setio response %d %s" % (streamdata.status_code, streamdata.text)) + + try: + streamdata = streamdata.json() + except: + raise APIException("Stream data returned is not JSON") ridedata = {} diff --git a/tapiriik/services/__init__.py b/tapiriik/services/__init__.py index cf0d4049b..0fbfe411d 100644 --- a/tapiriik/services/__init__.py +++ b/tapiriik/services/__init__.py @@ -32,6 +32,8 @@ BeginnerTriathlete = BeginnerTriathleteService() from tapiriik.services.Pulsstory import PulsstoryService Pulsstory = PulsstoryService() +from tapiriik.services.Setio import SetioService +Setio = SetioService() PRIVATE_SERVICES = [] try: diff --git a/tapiriik/web/static/img/services/Setio.png b/tapiriik/web/static/img/services/setio.png similarity index 100% rename from tapiriik/web/static/img/services/Setio.png rename to tapiriik/web/static/img/services/setio.png diff --git a/tapiriik/web/static/img/services/Setio_l.png b/tapiriik/web/static/img/services/setio_l.png similarity index 100% rename from tapiriik/web/static/img/services/Setio_l.png rename to tapiriik/web/static/img/services/setio_l.png