Skip to content

Commit

Permalink
Remove sträva rate limiting stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
cpfair committed Jul 17, 2015
1 parent 05b0f4a commit 750a0f1
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions tapiriik/services/Strava/strava.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,13 @@ def RetrieveAuthorizationToken(self, req, level):
code = req.GET.get("code")
params = {"grant_type": "authorization_code", "code": code, "client_id": STRAVA_CLIENT_ID, "client_secret": STRAVA_CLIENT_SECRET, "redirect_uri": WEB_ROOT + reverse("oauth_return", kwargs={"service": "strava"})}

self._globalRateLimit()
response = requests.post("https://www.strava.com/oauth/token", data=params)
if response.status_code != 200:
raise APIException("Invalid code")
data = response.json()

authorizationData = {"OAuthToken": data["access_token"]}
# Retrieve the user ID, meh.
self._globalRateLimit()
id_resp = requests.get("https://www.strava.com/api/v3/athlete", headers=self._apiHeaders(ServiceRecord({"Authorization": authorizationData})))
return (id_resp.json()["id"], authorizationData)

Expand All @@ -115,7 +113,6 @@ def DownloadActivityList(self, svcRecord, exhaustive=False):
if before is not None and before < 0:
break # Caused by activities that "happened" before the epoch. We generally don't care about those activities...
logger.debug("Req with before=" + str(before) + "/" + str(earliestDate))
self._globalRateLimit()
resp = requests.get("https://www.strava.com/api/v3/athletes/" + str(svcRecord.ExternalID) + "/activities", headers=self._apiHeaders(svcRecord), params={"before": before})
if resp.status_code == 401:
raise APIException("No authorization to retrieve activity list", block=True, user_exception=UserException(UserExceptionType.Authorization, intervention_required=True))
Expand Down Expand Up @@ -185,7 +182,6 @@ def DownloadActivity(self, svcRecord, activity):
return activity
activityID = activity.ServiceData["ActivityID"]

self._globalRateLimit()
streamdata = requests.get("https://www.strava.com/api/v3/activities/" + str(activityID) + "/streams/time,altitude,heartrate,cadence,watts,temp,moving,latlng,distance,velocity_smooth", headers=self._apiHeaders(svcRecord))
if streamdata.status_code == 401:
raise APIException("No authorization to download activity", block=True, user_exception=UserException(UserExceptionType.Authorization, intervention_required=True))
Expand Down Expand Up @@ -296,7 +292,6 @@ def UploadActivity(self, serviceRecord, activity):
fitData = FITIO.Dump(activity)
files = {"file":("tap-sync-" + activity.UID + "-" + str(os.getpid()) + ("-" + source_svc if source_svc else "") + ".fit", fitData)}

self._globalRateLimit()
response = requests.post("https://www.strava.com/api/v3/uploads", data=req, files=files, headers=self._apiHeaders(serviceRecord))
if response.status_code != 201:
if response.status_code == 401:
Expand All @@ -311,7 +306,6 @@ def UploadActivity(self, serviceRecord, activity):
upload_poll_wait = 8 # The mode of processing times
while not response.json()["activity_id"]:
time.sleep(upload_poll_wait)
self._globalRateLimit()
response = requests.get("https://www.strava.com/api/v3/uploads/%s" % upload_id, headers=self._apiHeaders(serviceRecord))
logger.debug("Waiting for upload - status %s id %s" % (response.json()["status"], response.json()["activity_id"]))
if response.json()["error"]:
Expand All @@ -334,7 +328,6 @@ def UploadActivity(self, serviceRecord, activity):
"elapsed_time": round((activity.EndTime - activity.StartTime).total_seconds())
}
headers = self._apiHeaders(serviceRecord)
self._globalRateLimit()
response = requests.post("https://www.strava.com/api/v3/activities", data=req, headers=headers)
# FFR this method returns the same dict as the activity listing, as REST services are wont to do.
if response.status_code != 201:
Expand Down

0 comments on commit 750a0f1

Please sign in to comment.