Compare commits
6 Commits
python-0.2
...
python-0.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
304f9fd0d3 | ||
|
|
dc0b3191f6 | ||
|
|
6a57a85e72 | ||
|
|
08a50c14bb | ||
|
|
ec2fe14ed3 | ||
|
|
305b010225 |
12
NEWS.md
12
NEWS.md
@@ -1,7 +1,17 @@
|
|||||||
|
Mar 13rd, 2019
|
||||||
|
==============
|
||||||
|
* Version `0.21.4` of the python library
|
||||||
|
* Fix TomTom bulk geocoder bug (#551)
|
||||||
|
|
||||||
|
Mar 5th, 2019
|
||||||
|
==============
|
||||||
|
* Version `0.21.3` of the python library
|
||||||
|
* Fixed TomTom Qps respondes part 2 (#546)
|
||||||
|
|
||||||
Mar 4th, 2019
|
Mar 4th, 2019
|
||||||
==============
|
==============
|
||||||
* Version `0.21.2` of the python library
|
* Version `0.21.2` of the python library
|
||||||
* Fixed TomTom Qps respondes (#546)
|
* Fixed TomTom Qps responses (#546)
|
||||||
|
|
||||||
Feb 25th, 2019
|
Feb 25th, 2019
|
||||||
==============
|
==============
|
||||||
|
|||||||
@@ -73,15 +73,19 @@ class TomTomGeocoder(Traceable):
|
|||||||
@qps_retry(qps=5, provider='tomtom')
|
@qps_retry(qps=5, provider='tomtom')
|
||||||
def geocode(self, searchtext, city=None, state_province=None,
|
def geocode(self, searchtext, city=None, state_province=None,
|
||||||
country=None):
|
country=None):
|
||||||
response = self.geocode_meta(searchtext, city, state_province, country)
|
geocoder_response, http_response = self._geocode_meta(searchtext, city, state_province, country)
|
||||||
error_message = response[1].get('error', None)
|
error_message = geocoder_response[1].get('error', None)
|
||||||
if error_message:
|
if error_message:
|
||||||
raise ServiceException(error_message, None)
|
raise ServiceException(error_message, http_response)
|
||||||
else:
|
else:
|
||||||
return response[0]
|
return geocoder_response[0]
|
||||||
|
|
||||||
|
def geocode_meta(self, searchtext, city=None, state_province=None,
|
||||||
|
country=None):
|
||||||
|
return self._geocode_meta(searchtext, city, state_province, country)[0]
|
||||||
|
|
||||||
@qps_retry(qps=5, provider='tomtom')
|
@qps_retry(qps=5, provider='tomtom')
|
||||||
def geocode_meta(self, searchtext, city=None, state_province=None,
|
def _geocode_meta(self, searchtext, city=None, state_province=None,
|
||||||
country=None):
|
country=None):
|
||||||
if searchtext:
|
if searchtext:
|
||||||
searchtext = searchtext.decode('utf-8')
|
searchtext = searchtext.decode('utf-8')
|
||||||
@@ -93,7 +97,7 @@ class TomTomGeocoder(Traceable):
|
|||||||
country = country.decode('utf-8')
|
country = country.decode('utf-8')
|
||||||
|
|
||||||
if not self._validate_input(searchtext, city, state_province, country):
|
if not self._validate_input(searchtext, city, state_province, country):
|
||||||
return EMPTY_RESPONSE
|
return (EMPTY_RESPONSE, None)
|
||||||
|
|
||||||
address = []
|
address = []
|
||||||
if searchtext and searchtext.strip():
|
if searchtext and searchtext.strip():
|
||||||
@@ -107,18 +111,18 @@ class TomTomGeocoder(Traceable):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
response = requests.get(uri)
|
response = requests.get(uri)
|
||||||
return self._parse_response(response.status_code, response.text)
|
return (self._parse_response(response.status_code, response.text), response)
|
||||||
except requests.Timeout as te:
|
except requests.Timeout as te:
|
||||||
# In case of timeout we want to stop the job because the server
|
# In case of timeout we want to stop the job because the server
|
||||||
# could be down
|
# could be down
|
||||||
msg = 'Timeout connecting to TomTom geocoding server'
|
msg = 'Timeout connecting to TomTom geocoding server'
|
||||||
self._logger.error(msg, te)
|
self._logger.error(msg, te)
|
||||||
return geocoder_error_response(msg)
|
return (geocoder_error_response(msg), None)
|
||||||
except requests.ConnectionError as ce:
|
except requests.ConnectionError as ce:
|
||||||
# Don't raise the exception to continue with the geocoding job
|
# Don't raise the exception to continue with the geocoding job
|
||||||
self._logger.error('Error connecting to TomTom geocoding server',
|
self._logger.error('Error connecting to TomTom geocoding server',
|
||||||
exception=ce)
|
exception=ce)
|
||||||
return EMPTY_RESPONSE
|
return (EMPTY_RESPONSE, None)
|
||||||
|
|
||||||
def _parse_response(self, status_code, text):
|
def _parse_response(self, status_code, text):
|
||||||
if status_code == requests.codes.ok:
|
if status_code == requests.codes.ok:
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from setuptools import setup, find_packages
|
|||||||
setup(
|
setup(
|
||||||
name='cartodb_services',
|
name='cartodb_services',
|
||||||
|
|
||||||
version='0.21.2',
|
version='0.21.4',
|
||||||
|
|
||||||
description='CartoDB Services API Python Library',
|
description='CartoDB Services API Python Library',
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user