Merge pull request #529 from CartoDB/development

Release version 0.20.2 for python library
This commit is contained in:
Mario de Frutos 2018-10-31 14:00:31 +01:00 committed by GitHub
commit 765b2f0901
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 4 deletions

12
NEWS.md
View File

@ -1,3 +1,15 @@
Oct 31th, 2018
==============
* Version `0.20.2` of the python library
* Added missing provider property to the QPS decorator in other TomTom services
* Now we only retry with the properly header coming from TomTom
Oct 3rd, 2018
==============
* Version `0.20.1` of the python library
* Fix QPS manager to retry with 403 status codes coming from TomTom
Sep 13th, 2018
==============
* Version `0.34.0` of the server, and `0.26.0` of the client.

View File

@ -16,6 +16,8 @@ The following functions provide an isoline generator service, based on time or d
Displays a contoured line on a map, connecting geometries to a defined area, measured by an equal range of distance (in meters).
Note that not all the providers, for example TomTom, provide us a way to define the isoline limit in distance so we need to make some estimations. Due that estimations the produced isolines could not be 100% precise.
#### Arguments
Name | Type | Description | Accepted values

View File

@ -70,7 +70,7 @@ class TomTomGeocoder(Traceable):
return False
@qps_retry(qps=5)
@qps_retry(qps=5, provider='tomtom')
def geocode(self, searchtext, city=None, state_province=None,
country=None):
response = self.geocode_meta(searchtext, city, state_province, country)
@ -80,7 +80,7 @@ class TomTomGeocoder(Traceable):
else:
return response[0]
@qps_retry(qps=5)
@qps_retry(qps=5, provider='tomtom')
def geocode_meta(self, searchtext, city=None, state_province=None,
country=None):
if searchtext:

View File

@ -89,7 +89,7 @@ class TomTomRouting(Traceable):
point[ENTRY_LONGITUDE]))
return geometry
@qps_retry(qps=5)
@qps_retry(qps=5, provider='tomtom')
def directions(self, waypoints, profile=DEFAULT_PROFILE,
date_time=DEFAULT_DEPARTAT):
self._validate_profile(profile)

View File

@ -6,6 +6,9 @@ from exceptions import TimeoutException
DEFAULT_RETRY_TIMEOUT = 60
DEFAULT_QUERIES_PER_SECOND = 10
TOMTOM_403_RATE_LIMIT_HEADER = 'Account Over Queries Per Second Limit'
TOMTOM_DETAIL_HEADER = 'X-Error-Detail-Header'
def qps_retry(original_function=None, **options):
""" Query Per Second retry decorator
@ -46,6 +49,8 @@ class QPSService:
response = getattr(e, 'response', None)
if response is not None:
if self._provider is not None and self._provider == 'tomtom' and (response.status_code == 403):
if response.headers.get(TOMTOM_DETAIL_HEADER) != TOMTOM_403_RATE_LIMIT_HEADER:
raise e
self.retry(start_time, attempt_number)
elif response.status_code == 429:
self.retry(start_time, attempt_number)

View File

@ -10,7 +10,7 @@ from setuptools import setup, find_packages
setup(
name='cartodb_services',
version='0.20.1',
version='0.20.2',
description='CartoDB Services API Python Library',