Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3af2a8f8f0 | ||
|
|
752d8317a2 | ||
|
|
8c5a4d32de | ||
|
|
0ba513d13d | ||
|
|
f29f0769d7 | ||
|
|
d625b26e57 | ||
|
|
62da0eff21 | ||
|
|
5f74d012a6 | ||
|
|
1505e0e6ea |
@@ -19,7 +19,7 @@ SELECT cartodb.cdb_conf_setconf('redis_metadata_config', '{"redis_host": "localh
|
|||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT cartodb.cdb_conf_setconf('heremaps_conf', '{"app_id": "dummy_id", "app_code": "dummy_code", "geocoder_cost_per_hit": 1}');
|
SELECT cartodb.cdb_conf_setconf('heremaps_conf', '{"geocoder": {"app_id": "dummy_id", "app_code": "dummy_code", "geocoder_cost_per_hit": 1}, "isolines": {"app_id": "dummy_id", "app_code": "dummy_code"}}');
|
||||||
cdb_conf_setconf
|
cdb_conf_setconf
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ CREATE EXTENSION cdb_dataservices_server;
|
|||||||
-- Mock the redis server connection to point to this very test db
|
-- Mock the redis server connection to point to this very test db
|
||||||
SELECT cartodb.cdb_conf_setconf('redis_metrics_config', '{"redis_host": "localhost", "redis_port": 6379, "timeout": 0.1, "redis_db": 5}');
|
SELECT cartodb.cdb_conf_setconf('redis_metrics_config', '{"redis_host": "localhost", "redis_port": 6379, "timeout": 0.1, "redis_db": 5}');
|
||||||
SELECT cartodb.cdb_conf_setconf('redis_metadata_config', '{"redis_host": "localhost", "redis_port": 6379, "timeout": 0.1, "redis_db": 5}');
|
SELECT cartodb.cdb_conf_setconf('redis_metadata_config', '{"redis_host": "localhost", "redis_port": 6379, "timeout": 0.1, "redis_db": 5}');
|
||||||
SELECT cartodb.cdb_conf_setconf('heremaps_conf', '{"app_id": "dummy_id", "app_code": "dummy_code", "geocoder_cost_per_hit": 1}');
|
SELECT cartodb.cdb_conf_setconf('heremaps_conf', '{"geocoder": {"app_id": "dummy_id", "app_code": "dummy_code", "geocoder_cost_per_hit": 1}, "isolines": {"app_id": "dummy_id", "app_code": "dummy_code"}}');
|
||||||
SELECT cartodb.cdb_conf_setconf('mapzen_conf', '{"routing_app_key": "dummy_key", "geocoder_app_key": "dummy_key"}');
|
SELECT cartodb.cdb_conf_setconf('mapzen_conf', '{"routing_app_key": "dummy_key", "geocoder_app_key": "dummy_key"}');
|
||||||
SELECT cartodb.cdb_conf_setconf('logger_conf', '{"geocoder_log_path": "/dev/null"}');
|
SELECT cartodb.cdb_conf_setconf('logger_conf', '{"geocoder_log_path": "/dev/null"}');
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import time
|
import time
|
||||||
|
import random
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from exceptions import TimeoutException
|
from exceptions import TimeoutException
|
||||||
|
|
||||||
|
|||||||
@@ -54,10 +54,10 @@ class IsolinesRoutingConfig(ServiceConfig):
|
|||||||
|
|
||||||
ROUTING_CONFIG_KEYS = ['here_isolines_quota', 'soft_here_isolines_limit',
|
ROUTING_CONFIG_KEYS = ['here_isolines_quota', 'soft_here_isolines_limit',
|
||||||
'period_end_date', 'username', 'orgname',
|
'period_end_date', 'username', 'orgname',
|
||||||
'heremaps_app_id', 'heremaps_app_code',
|
'heremaps_isolines_app_id', 'heremaps_isolines_app_code',
|
||||||
'geocoder_type']
|
'geocoder_type']
|
||||||
NOKIA_APP_ID_KEY = 'heremaps_app_id'
|
NOKIA_APP_ID_KEY = 'heremaps_isolines_app_id'
|
||||||
NOKIA_APP_CODE_KEY = 'heremaps_app_code'
|
NOKIA_APP_CODE_KEY = 'heremaps_isolines_app_code'
|
||||||
QUOTA_KEY = 'here_isolines_quota'
|
QUOTA_KEY = 'here_isolines_quota'
|
||||||
SOFT_LIMIT_KEY = 'soft_here_isolines_limit'
|
SOFT_LIMIT_KEY = 'soft_here_isolines_limit'
|
||||||
USERNAME_KEY = 'username'
|
USERNAME_KEY = 'username'
|
||||||
@@ -102,8 +102,8 @@ class IsolinesRoutingConfig(ServiceConfig):
|
|||||||
self._soft_isolines_limit = True
|
self._soft_isolines_limit = True
|
||||||
else:
|
else:
|
||||||
self._soft_isolines_limit = False
|
self._soft_isolines_limit = False
|
||||||
self._heremaps_app_id = db_config.heremaps_app_id
|
self._heremaps_app_id = db_config.heremaps_isolines_app_id
|
||||||
self._heremaps_app_code = db_config.heremaps_app_code
|
self._heremaps_app_code = db_config.heremaps_isolines_app_code
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def service_type(self):
|
def service_type(self):
|
||||||
@@ -168,12 +168,12 @@ class GeocoderConfig(ServiceConfig):
|
|||||||
GEOCODER_CONFIG_KEYS = ['google_maps_client_id', 'google_maps_api_key',
|
GEOCODER_CONFIG_KEYS = ['google_maps_client_id', 'google_maps_api_key',
|
||||||
'geocoding_quota', 'soft_geocoding_limit',
|
'geocoding_quota', 'soft_geocoding_limit',
|
||||||
'geocoder_type', 'period_end_date',
|
'geocoder_type', 'period_end_date',
|
||||||
'heremaps_app_id', 'heremaps_app_code',
|
'heremaps_geocoder_app_id', 'heremaps_geocoder_app_code',
|
||||||
'mapzen_geocoder_app_key', 'username', 'orgname']
|
'mapzen_geocoder_app_key', 'username', 'orgname']
|
||||||
NOKIA_GEOCODER_REDIS_MANDATORY_KEYS = ['geocoding_quota', 'soft_geocoding_limit']
|
NOKIA_GEOCODER_REDIS_MANDATORY_KEYS = ['geocoding_quota', 'soft_geocoding_limit']
|
||||||
NOKIA_GEOCODER = 'heremaps'
|
NOKIA_GEOCODER = 'heremaps'
|
||||||
NOKIA_GEOCODER_APP_ID_KEY = 'heremaps_app_id'
|
NOKIA_GEOCODER_APP_ID_KEY = 'heremaps_geocoder_app_id'
|
||||||
NOKIA_GEOCODER_APP_CODE_KEY = 'heremaps_app_code'
|
NOKIA_GEOCODER_APP_CODE_KEY = 'heremaps_geocoder_app_code'
|
||||||
GOOGLE_GEOCODER = 'google'
|
GOOGLE_GEOCODER = 'google'
|
||||||
GOOGLE_GEOCODER_API_KEY = 'google_maps_api_key'
|
GOOGLE_GEOCODER_API_KEY = 'google_maps_api_key'
|
||||||
GOOGLE_GEOCODER_CLIENT_ID = 'google_maps_client_id'
|
GOOGLE_GEOCODER_CLIENT_ID = 'google_maps_client_id'
|
||||||
@@ -241,8 +241,8 @@ class GeocoderConfig(ServiceConfig):
|
|||||||
else:
|
else:
|
||||||
self._soft_geocoding_limit = False
|
self._soft_geocoding_limit = False
|
||||||
if filtered_config[self.GEOCODER_TYPE].lower() == self.NOKIA_GEOCODER:
|
if filtered_config[self.GEOCODER_TYPE].lower() == self.NOKIA_GEOCODER:
|
||||||
self._heremaps_app_id = db_config.heremaps_app_id
|
self._heremaps_app_id = db_config.heremaps_geocoder_app_id
|
||||||
self._heremaps_app_code = db_config.heremaps_app_code
|
self._heremaps_app_code = db_config.heremaps_geocoder_app_code
|
||||||
self._cost_per_hit = db_config.heremaps_geocoder_cost_per_hit
|
self._cost_per_hit = db_config.heremaps_geocoder_cost_per_hit
|
||||||
elif filtered_config[self.GEOCODER_TYPE].lower() == self.GOOGLE_GEOCODER:
|
elif filtered_config[self.GEOCODER_TYPE].lower() == self.GOOGLE_GEOCODER:
|
||||||
self._google_maps_api_key = filtered_config[self.GOOGLE_GEOCODER_API_KEY]
|
self._google_maps_api_key = filtered_config[self.GOOGLE_GEOCODER_API_KEY]
|
||||||
@@ -338,10 +338,12 @@ class ServicesDBConfig:
|
|||||||
raise ConfigException('Here maps configuration missing')
|
raise ConfigException('Here maps configuration missing')
|
||||||
else:
|
else:
|
||||||
heremaps_conf = json.loads(heremaps_conf_json)
|
heremaps_conf = json.loads(heremaps_conf_json)
|
||||||
self._heremaps_app_id = heremaps_conf['app_id']
|
self._heremaps_geocoder_app_id = heremaps_conf['geocoder']['app_id']
|
||||||
self._heremaps_app_code = heremaps_conf['app_code']
|
self._heremaps_geocoder_app_code = heremaps_conf['geocoder']['app_code']
|
||||||
self._heremaps_geocoder_cost_per_hit = heremaps_conf[
|
self._heremaps_geocoder_cost_per_hit = heremaps_conf['geocoder'][
|
||||||
'geocoder_cost_per_hit']
|
'geocoder_cost_per_hit']
|
||||||
|
self._heremaps_isolines_app_id = heremaps_conf['isolines']['app_id']
|
||||||
|
self._heremaps_isolines_app_code = heremaps_conf['isolines']['app_code']
|
||||||
|
|
||||||
def _get_mapzen_config(self):
|
def _get_mapzen_config(self):
|
||||||
mapzen_conf_json = self._get_conf('mapzen_conf')
|
mapzen_conf_json = self._get_conf('mapzen_conf')
|
||||||
@@ -369,12 +371,20 @@ class ServicesDBConfig:
|
|||||||
raise ConfigException("Malformed config for {0}: {1}".format(key, e))
|
raise ConfigException("Malformed config for {0}: {1}".format(key, e))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def heremaps_app_id(self):
|
def heremaps_isolines_app_id(self):
|
||||||
return self._heremaps_app_id
|
return self._heremaps_isolines_app_id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def heremaps_app_code(self):
|
def heremaps_isolines_app_code(self):
|
||||||
return self._heremaps_app_code
|
return self._heremaps_isolines_app_code
|
||||||
|
|
||||||
|
@property
|
||||||
|
def heremaps_geocoder_app_id(self):
|
||||||
|
return self._heremaps_geocoder_app_id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def heremaps_geocoder_app_code(self):
|
||||||
|
return self._heremaps_geocoder_app_code
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def heremaps_geocoder_cost_per_hit(self):
|
def heremaps_geocoder_cost_per_hit(self):
|
||||||
|
|||||||
@@ -23,14 +23,15 @@ class RedisConnection:
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
conn = StrictRedis(host=self._config.host, port=self._config.port,
|
conn = StrictRedis(host=self._config.host, port=self._config.port,
|
||||||
db=self._config.db)
|
db=self._config.db,
|
||||||
|
socket_timeout=self._config.timeout)
|
||||||
return conn
|
return conn
|
||||||
|
|
||||||
|
|
||||||
class RedisDBConfig:
|
class RedisDBConfig:
|
||||||
|
|
||||||
DEFAULT_USER_DB = 5
|
DEFAULT_USER_DB = 5
|
||||||
DEFAULT_TIMEOUT = 2 # seconds
|
DEFAULT_TIMEOUT = 1.5 # seconds
|
||||||
|
|
||||||
def __init__(self, key, db_conn):
|
def __init__(self, key, db_conn):
|
||||||
self._db_conn = db_conn
|
self._db_conn = db_conn
|
||||||
@@ -63,8 +64,9 @@ class RedisDBConfig:
|
|||||||
self._sentinel_id = None
|
self._sentinel_id = None
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Host: {0}, Port: {1}, Sentinel id: {2}, DB: {3}".format(
|
return "Host: {0}, Port: {1}, Sentinel id: {2}, DB: {3}, " \
|
||||||
self.host, self.port, self.sentinel_id, self.db)
|
"Timeout: {4}".format(self.host, self.port, self.sentinel_id,
|
||||||
|
self.db, self.timeout)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def host(self):
|
def host(self):
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from setuptools import setup, find_packages
|
|||||||
setup(
|
setup(
|
||||||
name='cartodb_services',
|
name='cartodb_services',
|
||||||
|
|
||||||
version='0.4.0',
|
version='0.4.2',
|
||||||
|
|
||||||
description='CartoDB Services API Python Library',
|
description='CartoDB Services API Python Library',
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ def build_plpy_mock(empty=False):
|
|||||||
|
|
||||||
def _plpy_execute_side_effect(*args, **kwargs):
|
def _plpy_execute_side_effect(*args, **kwargs):
|
||||||
if args[0] == "SELECT cartodb.CDB_Conf_GetConf('heremaps_conf') as conf":
|
if args[0] == "SELECT cartodb.CDB_Conf_GetConf('heremaps_conf') as conf":
|
||||||
return [{'conf': '{"app_id": "app_id", "app_code": "code", "geocoder_cost_per_hit": 1}'}]
|
return [{'conf': '{"geocoder": {"app_id": "app_id", "app_code": "code", "geocoder_cost_per_hit": 1}, "isolines": {"app_id": "app_id", "app_code": "code"}}'}]
|
||||||
elif args[0] == "SELECT cartodb.CDB_Conf_GetConf('mapzen_conf') as conf":
|
elif args[0] == "SELECT cartodb.CDB_Conf_GetConf('mapzen_conf') as conf":
|
||||||
return [{'conf': '{"routing_app_key": "app_key", "geocoder_app_key": "app_key"}'}]
|
return [{'conf': '{"routing_app_key": "app_key", "geocoder_app_key": "app_key"}'}]
|
||||||
elif args[0] == "SELECT cartodb.CDB_Conf_GetConf('logger_conf') as conf":
|
elif args[0] == "SELECT cartodb.CDB_Conf_GetConf('logger_conf') as conf":
|
||||||
|
|||||||
Reference in New Issue
Block a user