Solving errors and refactor
This commit is contained in:
@@ -2,4 +2,3 @@ from routing import MapboxRouting, MapboxRoutingResponse
|
||||
from geocoder import MapboxGeocoder
|
||||
from isolines import MapboxIsolines, MapboxIsochronesResponse
|
||||
from matrix_client import MapboxMatrixClient
|
||||
from exceptions import ServiceException
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
'''
|
||||
Exceptions for the Mapbox services Python wrapper.
|
||||
'''
|
||||
|
||||
|
||||
class ServiceException(Exception):
|
||||
'''
|
||||
Exception to be raised if any Service problem is found.
|
||||
'''
|
||||
|
||||
def __init__(self, code, message):
|
||||
self.code = code
|
||||
self.message = message
|
||||
|
||||
def __str__(self):
|
||||
return repr('ServiceException ({code}): {message}'.format(
|
||||
code=self.code,
|
||||
message=self.message))
|
||||
@@ -6,7 +6,7 @@ import json
|
||||
import requests
|
||||
from mapbox import Geocoder
|
||||
from cartodb_services.metrics import Traceable
|
||||
from cartodb_services.mapbox.exceptions import ServiceException
|
||||
from cartodb_services.tools.exceptions import ServiceException
|
||||
from cartodb_services.tools.qps import qps_retry
|
||||
|
||||
GEOCODER_NAME = 'geocoder_name'
|
||||
@@ -69,4 +69,4 @@ class MapboxGeocoder(Traceable):
|
||||
if response.status_code == requests.codes.ok:
|
||||
return self._parse_geocoder_response(response.text)
|
||||
else:
|
||||
raise ServiceException(response.status_code, response.content)
|
||||
raise ServiceException(response.status_code, response)
|
||||
|
||||
@@ -6,7 +6,7 @@ import requests
|
||||
from cartodb_services.metrics import Traceable
|
||||
from cartodb_services.tools.coordinates import (validate_coordinates,
|
||||
marshall_coordinates)
|
||||
from exceptions import ServiceException
|
||||
from cartodb_services.tools.exceptions import ServiceException
|
||||
from cartodb_services.tools.qps import qps_retry
|
||||
|
||||
BASEURI = ('https://api.mapbox.com/directions-matrix/v1/mapbox/{profile}/'
|
||||
@@ -69,4 +69,4 @@ class MapboxMatrixClient(Traceable):
|
||||
if response.status_code == requests.codes.ok:
|
||||
return response.text
|
||||
else:
|
||||
raise ServiceException(response.status_code, response.content)
|
||||
raise ServiceException(response.status_code, response)
|
||||
|
||||
@@ -8,7 +8,7 @@ from cartodb_services.metrics import Traceable
|
||||
from cartodb_services.tools import PolyLine
|
||||
from cartodb_services.tools.coordinates import (validate_coordinates,
|
||||
marshall_coordinates)
|
||||
from cartodb_services.mapbox.exceptions import ServiceException
|
||||
from cartodb_services.tools.exceptions import ServiceException
|
||||
from cartodb_services.tools.qps import qps_retry
|
||||
|
||||
BASEURI = ('https://api.mapbox.com/directions/v5/mapbox/{profile}/'
|
||||
@@ -86,7 +86,7 @@ class MapboxRouting(Traceable):
|
||||
elif response.status_code == requests.codes.bad_request:
|
||||
return MapboxRoutingResponse(None, None, None)
|
||||
else:
|
||||
raise ServiceException(response.status_code, response.content)
|
||||
raise ServiceException(response.status_code, response)
|
||||
|
||||
|
||||
class MapboxRoutingResponse:
|
||||
|
||||
Reference in New Issue
Block a user