|
|
@ -5,6 +5,7 @@ from __future__ import (absolute_import, division, print_function,
|
|
|
|
import sys
|
|
|
|
import sys
|
|
|
|
import importlib
|
|
|
|
import importlib
|
|
|
|
import time
|
|
|
|
import time
|
|
|
|
|
|
|
|
import os
|
|
|
|
from functools import partial
|
|
|
|
from functools import partial
|
|
|
|
|
|
|
|
|
|
|
|
import click
|
|
|
|
import click
|
|
|
@ -48,12 +49,21 @@ def get_redis_from_config(settings, connection_class=Redis):
|
|
|
|
sn = Sentinel(instances, socket_timeout=socket_timeout, password=password, db=db)
|
|
|
|
sn = Sentinel(instances, socket_timeout=socket_timeout, password=password, db=db)
|
|
|
|
return sn.master_for(master_name)
|
|
|
|
return sn.master_for(master_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ssl = settings.get('REDIS_SSL', False)
|
|
|
|
|
|
|
|
if isinstance(ssl, str):
|
|
|
|
|
|
|
|
if ssl.lower() in ['y', 'yes', 't', 'true']:
|
|
|
|
|
|
|
|
ssl = True
|
|
|
|
|
|
|
|
elif ssl.lower() in ['n', 'no', 'f', 'false', '']:
|
|
|
|
|
|
|
|
ssl = False
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
raise ValueError('REDIS_SSL is a boolean and must be "True" or "False".')
|
|
|
|
|
|
|
|
|
|
|
|
kwargs = {
|
|
|
|
kwargs = {
|
|
|
|
'host': settings.get('REDIS_HOST', 'localhost'),
|
|
|
|
'host': settings.get('REDIS_HOST', 'localhost'),
|
|
|
|
'port': settings.get('REDIS_PORT', 6379),
|
|
|
|
'port': settings.get('REDIS_PORT', 6379),
|
|
|
|
'db': settings.get('REDIS_DB', 0),
|
|
|
|
'db': settings.get('REDIS_DB', 0),
|
|
|
|
'password': settings.get('REDIS_PASSWORD', None),
|
|
|
|
'password': settings.get('REDIS_PASSWORD', None),
|
|
|
|
'ssl': settings.get('REDIS_SSL', False),
|
|
|
|
'ssl': ssl,
|
|
|
|
'ssl_ca_certs': settings.get('REDIS_SSL_CA_CERTS', None),
|
|
|
|
'ssl_ca_certs': settings.get('REDIS_SSL_CA_CERTS', None),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -235,8 +245,11 @@ class CliConfig:
|
|
|
|
if self._connection is None:
|
|
|
|
if self._connection is None:
|
|
|
|
if self.url:
|
|
|
|
if self.url:
|
|
|
|
self._connection = self.connection_class.from_url(self.url)
|
|
|
|
self._connection = self.connection_class.from_url(self.url)
|
|
|
|
else:
|
|
|
|
elif self.config:
|
|
|
|
settings = read_config_file(self.config) if self.config else {}
|
|
|
|
settings = read_config_file(self.config) if self.config else {}
|
|
|
|
self._connection = get_redis_from_config(settings,
|
|
|
|
self._connection = get_redis_from_config(settings,
|
|
|
|
self.connection_class)
|
|
|
|
self.connection_class)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self._connection = get_redis_from_config(os.environ,
|
|
|
|
|
|
|
|
self.connection_class)
|
|
|
|
return self._connection
|
|
|
|
return self._connection
|
|
|
|