From 6e54507b5a6af9782cfa92e6a7ca8a4ca503b48e Mon Sep 17 00:00:00 2001 From: Mario de Frutos Date: Fri, 2 Feb 2018 12:06:33 +0100 Subject: [PATCH 1/2] Move exceptions to a proper place --- .../cartodb_services/tools/__init__.py | 3 ++- .../cartodb_services/tools/exceptions.py | 9 ++++++++- .../cartodb_services/tools/service_manager.py | 10 +--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/server/lib/python/cartodb_services/cartodb_services/tools/__init__.py b/server/lib/python/cartodb_services/cartodb_services/tools/__init__.py index d8ca7f1..21c213b 100644 --- a/server/lib/python/cartodb_services/cartodb_services/tools/__init__.py +++ b/server/lib/python/cartodb_services/cartodb_services/tools/__init__.py @@ -3,5 +3,6 @@ from coordinates import Coordinate from polyline import PolyLine from log import Logger, LoggerConfig from rate_limiter import RateLimiter -from service_manager import ServiceManager, RateLimitExceeded, QuotaExceededException +from service_manager import ServiceManager, RateLimitExceeded from legacy_service_manager import LegacyServiceManager +from exceptions import QuotaExceededException, RateLimitExceeded diff --git a/server/lib/python/cartodb_services/cartodb_services/tools/exceptions.py b/server/lib/python/cartodb_services/cartodb_services/tools/exceptions.py index a970679..f34822e 100644 --- a/server/lib/python/cartodb_services/cartodb_services/tools/exceptions.py +++ b/server/lib/python/cartodb_services/cartodb_services/tools/exceptions.py @@ -1,6 +1,5 @@ import json - class TimeoutException(Exception): def __str__(self): return repr('Timeout requesting to server') @@ -29,3 +28,11 @@ class WrongParams(Exception): class MalformedResult(Exception): def __str__(self): return repr('Result structure is malformed') + +class RateLimitExceeded(Exception): + def __str__(self): + return repr('Rate limit exceeded') + +class QuotaExceededException(Exception): + def __str__(self): + return repr('You have reached the limit of your quota') diff --git a/server/lib/python/cartodb_services/cartodb_services/tools/service_manager.py b/server/lib/python/cartodb_services/cartodb_services/tools/service_manager.py index fd0d926..a8fa711 100644 --- a/server/lib/python/cartodb_services/cartodb_services/tools/service_manager.py +++ b/server/lib/python/cartodb_services/cartodb_services/tools/service_manager.py @@ -1,20 +1,12 @@ from cartodb_services.metrics import QuotaService from cartodb_services.tools import Logger from cartodb_services.tools import RateLimiter +from cartodb_services.tools import QuotaExceededException, RateLimitExceeded from cartodb_services.refactor.tools.logger import LoggerConfigBuilder from cartodb_services.refactor.backend.redis_metrics_connection import RedisMetricsConnectionFactory from cartodb_services.config import ServiceConfiguration, RateLimitsConfigBuilder -class RateLimitExceeded(Exception): - def __str__(self): - return repr('Rate limit exceeded') - -class QuotaExceededException(Exception): - def __str__(self): - return repr('You have reached the limit of your quota') - - class ServiceManagerBase: """ A Service manager collects the configuration needed to use a service, From 5c7d1e9ac15af6f5af9bbd2dac910a5e4d129c74 Mon Sep 17 00:00:00 2001 From: Mario de Frutos Date: Fri, 2 Feb 2018 12:29:48 +0100 Subject: [PATCH 2/2] Solve some dependencies bugs --- .../cartodb_services/cartodb_services/tools/__init__.py | 3 ++- .../cartodb_services/tools/service_manager.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/server/lib/python/cartodb_services/cartodb_services/tools/__init__.py b/server/lib/python/cartodb_services/cartodb_services/tools/__init__.py index 21c213b..976469a 100644 --- a/server/lib/python/cartodb_services/cartodb_services/tools/__init__.py +++ b/server/lib/python/cartodb_services/cartodb_services/tools/__init__.py @@ -3,6 +3,7 @@ from coordinates import Coordinate from polyline import PolyLine from log import Logger, LoggerConfig from rate_limiter import RateLimiter -from service_manager import ServiceManager, RateLimitExceeded +from service_manager import ServiceManager from legacy_service_manager import LegacyServiceManager from exceptions import QuotaExceededException, RateLimitExceeded +from country import country_to_iso3 diff --git a/server/lib/python/cartodb_services/cartodb_services/tools/service_manager.py b/server/lib/python/cartodb_services/cartodb_services/tools/service_manager.py index a8fa711..4dd8f9a 100644 --- a/server/lib/python/cartodb_services/cartodb_services/tools/service_manager.py +++ b/server/lib/python/cartodb_services/cartodb_services/tools/service_manager.py @@ -1,7 +1,7 @@ from cartodb_services.metrics import QuotaService -from cartodb_services.tools import Logger -from cartodb_services.tools import RateLimiter -from cartodb_services.tools import QuotaExceededException, RateLimitExceeded +from cartodb_services.tools.log import Logger +from cartodb_services.tools.rate_limiter import RateLimiter +from cartodb_services.tools.exceptions import QuotaExceededException, RateLimitExceeded from cartodb_services.refactor.tools.logger import LoggerConfigBuilder from cartodb_services.refactor.backend.redis_metrics_connection import RedisMetricsConnectionFactory from cartodb_services.config import ServiceConfiguration, RateLimitsConfigBuilder