def get_redis_from_config(settings, connection_class=StrictRedis):
 if (settings.get(u'REDIS_URL') is not None):
  return connection_class.from_url(settings[u'REDIS_URL'])
 kwargs = {u'host': settings.get(u'REDIS_HOST', u'localhost'), u'port': settings.get(u'REDIS_PORT', 6379), u'db': settings.get(u'REDIS_DB', 0), u'password': settings.get(u'REDIS_PASSWORD', None)}
 use_ssl = settings.get(u'REDIS_SSL', False)
 if use_ssl:
  def safeint(x):
   try:
    return int(x)
   except ValueError:
    return 0
  version_info = tuple((safeint(x) for x in redis.__version__.split(u'.')))
  if (not (version_info >= (2, 10))):
   raise RuntimeError(u'Using SSL requires a redis-py version >= 2.10')
  kwargs[u'ssl'] = use_ssl
 return connection_class(**kwargs)

def get_redis_from_config ( settings , connection_class = StrictRedis ) : if ( settings . get ( u'REDIS_URL' ) is not None ) : return connection_class . from_url ( settings [ u'REDIS_URL' ] ) kwargs = { u'host' : settings . get ( u'REDIS_HOST' , u'localhost' ) , u'port' : settings . get ( u'REDIS_PORT' , 6379 ) , u'db' : settings . get ( u'REDIS_DB' , 0 ) , u'password' : settings . get ( u'REDIS_PASSWORD' , None ) } use_ssl = settings . get ( u'REDIS_SSL' , False ) if use_ssl : def safeint ( x ) : try : return int ( x ) except ValueError : return 0 version_info = tuple ( ( safeint ( x ) for x in redis . __version__ . split ( u'.' ) ) ) if ( not ( version_info >= ( 2 , 10 ) ) ) : raise RuntimeError ( u'Using SSL requires a redis-py version >= 2.10' ) kwargs [ u'ssl' ] = use_ssl return connection_class ( ** kwargs )
returns a strictredis instance from a dictionary of settings .