Sets BROKER_URL depending on redis or rabbitmq settings
431612
def BROKER_URL(self):
        """"""

        # also allow specify broker_url
        broker_url = get('BROKER_URL', None)
        if broker_url:
            log.info("Using BROKER_URL setting: {}".format(broker_url))
            return broker_url

        redis_available = self._redis_available()
        broker_type = self.BROKER_TYPE

        if broker_type == 'redis' and not redis_available:
            log.warn("Choosed broker type is redis, but redis not available. \
                    Check redis package, and REDIS_HOST, REDIS_PORT settings")

        if broker_type == 'redis' and redis_available:

            return 'redis://{host}:{port}/{db}'.format(
                    host=self.REDIS_HOST,
                    port=self.REDIS_PORT,
                    db=self.CELERY_REDIS_BROKER_DB)
        elif broker_type == 'rabbitmq':
            return 'amqp://{user}:{passwd}@{host}:{port}/{vhost}'.format(
                    user=self.RABBITMQ_USER,
                    passwd=self.RABBITMQ_PASSWD,
                    host=self.RABBITMQ_HOST,
                    port=self.RABBITMQ_PORT,
                    vhost=self.RABBITMQ_VHOST)
        else:
            return DEFAULT_BROKER_URL
210888
def setScoop(self):
        """"""
        scoop.IS_RUNNING = True
        scoop.IS_ORIGIN = self.args.origin
        scoop.BROKER = BrokerInfo(
            self.args.brokerHostname,
            self.args.taskPort,
            self.args.metaPort,
            self.args.externalBrokerHostname
                if self.args.externalBrokerHostname
                else self.args.brokerHostname,
        )
        scoop.SIZE = self.args.size
        scoop.DEBUG = self.args.debug
        scoop.MAIN_MODULE = self.args.executable
        scoop.CONFIGURATION = {
          'headless': not bool(self.args.executable),
          'backend': self.args.backend,
        }
        scoop.WORKING_DIRECTORY = self.args.workingDirectory
        scoop.logger = self.log
        if self.args.nice:
            if not psutil:
                scoop.logger.error("psutil not installed.")
                raise ImportError("psutil is needed for nice functionnality.")
            p = psutil.Process(os.getpid())
            p.set_nice(self.args.nice)

        if scoop.DEBUG or self.args.profile:
            from scoop import _debug

        if scoop.DEBUG:
            _debug.createDirectory()
741284
function RedisIssueDao(client) {
	this.client = client;
	this.prefix = "omega:";

	console.log('storing issues in: redis://' + this.client.host + ':' + this.client.port + '/' + this.prefix);
}
737708
def _broks(self, broker_name):  # pylint: disable=unused-argument
        
        with self.app.broks_lock:
            res = self.app.get_broks()
        return serialize(res, True)
247358
def set(self, key, value):
        """"""
        value = pickle.dumps(value, protocol=constants.PICKLE_PROTOCOL)
        redis_conn.set(key, value)
785402
def _connect_broker(self):
        
        if not self.broker:
            self.broker = mitogen.master.Broker()
            self.router, self.parent = mitogen.unix.connect(
                path=ansible_mitogen.process.MuxProcess.unix_listener_path,
                broker=self.broker,
            )
1019213
def set_connections_params(self, harakiri=None, timeout_socket=None):
        
        self._set_aliased('harakiri', harakiri)
        self._set_aliased('timeout', timeout_socket)

        return self
876264
def setnx(msg_id, suffix, value)
      with_failover { redis.setnx(key(msg_id, suffix), value) }
    end
628452
def set_proxy(url, basic_auth=None):
    
    global _pools, _onetime_pool_spec
    if not url:
        _pools['default'] = urllib3.PoolManager(**_default_pool_params)
        _onetime_pool_spec = (urllib3.PoolManager, _onetime_pool_params)
    elif basic_auth:
        h = urllib3.make_headers(proxy_basic_auth=':'.join(basic_auth))
        _pools['default'] = urllib3.ProxyManager(url, proxy_headers=h, **_default_pool_params)
        _onetime_pool_spec = (urllib3.ProxyManager, dict(proxy_url=url, proxy_headers=h, **_onetime_pool_params))
    else:
        _pools['default'] = urllib3.ProxyManager(url, **_default_pool_params)
        _onetime_pool_spec = (urllib3.ProxyManager, dict(proxy_url=url, **_onetime_pool_params))
198315
function(options){
  var _this = this;

  this.handlers = {};

  if(!options){
    options = {};
  }

  if(!options.redis){
    options.redis = {};
  }

  this.options = {
    id: options.id || shortId.generate(),
    autoConfig: options.autoConfig ||  false,
    dataExpiry: options.dataExpiry || 30,
    redis: {
      port: options.redis.port || 6379,
      host: options.redis.host || '127.0.0.1',
      redis: options.redis.options || {}
    }
  };

  //Create redis clients
  this.redisSub = redis.createClient(this.options.redis.port, this.options.redis.host, this.options.redis.options);
  this.redis = redis.createClient(this.options.redis.port, this.options.redis.host, this.options.redis.options);
  this.redisInstant = redis.createClient(this.options.redis.port, this.options.redis.host, this.options.redis.options);

  //Attempt auto config
  if(this.options.autoConfig){
    var config = '';
    this.redis.config("GET", "notify-keyspace-events", function(err, data){
      if(data){
        config = data[1];
      }
      if(config.indexOf('E') == -1){
        config += 'E'
      }
      if(config.indexOf('x') == -1){
        config += 'x'
      }
      _this.redis.config("SET", "notify-keyspace-events", config)
    });
  }

  //Listen to key expiry notifications and handle events
  var expiryListener = new RedisEvent(this.redisSub, 'expired', /redular:(.+):(.+):(.+)/);
  expiryListener.defineHandler(function(key){
    var clientId = key[1];
    var eventName = key[2];
    var eventId = key[3];

    _this.redis.get('redular-data:' + clientId + ':' + eventName + ':' + eventId, function(err, data){
      if(data){
        data = JSON.parse(data);
      }
      if(clientId == _this.options.id || clientId == 'global'){
        _this.handleEvent(eventName, data);
      }
    });
  });

  //Listen to instant events and handle them
  this.redisInstant.subscribe('redular:instant');
  this.redisInstant.on('message', function(channel, message){
    try{
      var parsedMessage = JSON.parse(message);
    } catch (e){
      throw e;
    }
    if(parsedMessage.client == _this.options.id || parsedMessage.client == 'global') {
      _this.handleEvent(parsedMessage.event, parsedMessage.data);
    }
  });

}
443948
def reconfigure_messaging(self, msg_host, msg_port):
        ''''''
        self._messaging.create_external_route(
            'rabbitmq', host=msg_host, port=msg_port)
776822
def create_connection():
    """"""
    # REDIS_URL is defined in .env and loaded into the environment by Honcho
    redis_url = os.getenv('REDIS_URL')
    # If it's not defined, use the Redis default
    if not redis_url:
        redis_url = 'redis://localhost:6379'
    urlparse.uses_netloc.append('redis')
    url = urlparse.urlparse(redis_url)
    return redis.StrictRedis(
        host=url.hostname,
        port=url.port,
        db=0,
        password=url.password
    )
480038
def ConfigureUrls(config, external_hostname = None):
  """"""
  print("\n\n-=GRR URLs=-\n"
        "For GRR to work each client has to be able to communicate with the\n"
        "server. To do this we normally need a public dns name or IP address\n"
        "to communicate with. In the standard configuration this will be used\n"
        "to host both the client facing server and the admin user interface.\n")

  existing_ui_urn = grr_config.CONFIG.Get("AdminUI.url", default=None)
  existing_frontend_urns = grr_config.CONFIG.Get("Client.server_urls")
  if not existing_frontend_urns:
    # Port from older deprecated setting Client.control_urls.
    existing_control_urns = grr_config.CONFIG.Get(
        "Client.control_urls", default=None)
    if existing_control_urns is not None:
      existing_frontend_urns = []
      for existing_control_urn in existing_control_urns:
        if not existing_control_urn.endswith("control"):
          raise RuntimeError("Invalid existing control URL: %s" %
                             existing_control_urn)

        existing_frontend_urns.append(
            existing_control_urn.rsplit("/", 1)[0] + "/")

      config.Set("Client.server_urls", existing_frontend_urns)
      config.Set("Client.control_urls", ["deprecated use Client.server_urls"])

  if not existing_frontend_urns or not existing_ui_urn:
    ConfigureHostnames(config, external_hostname=external_hostname)
  else:
    print("Found existing settings:\n  AdminUI URL: %s\n  "
          "Frontend URL(s): %s\n" % (existing_ui_urn, existing_frontend_urns))
    if not RetryBoolQuestion("Do you want to keep this configuration?", True):
      ConfigureHostnames(config, external_hostname=external_hostname)
346773
def set(msg_id, suffix, value)
      with_failover { redis.set(key(msg_id, suffix), value) }
    end
195357
def _get_redis_server(opts=None):
    '''
    
    '''
    global REDIS_SERVER
    if REDIS_SERVER:
        return REDIS_SERVER
    if not opts:
        opts = _get_redis_cache_opts()

    if opts['cluster_mode']:
        REDIS_SERVER = StrictRedisCluster(startup_nodes=opts['startup_nodes'],
                                          skip_full_coverage_check=opts['skip_full_coverage_check'])
    else:
        REDIS_SERVER = redis.StrictRedis(opts['host'],
                                   opts['port'],
                                   unix_socket_path=opts['unix_socket_path'],
                                   db=opts['db'],
                                   password=opts['password'])
    return REDIS_SERVER
656845
function RedisBackend(port, hostname, opts)
{
	if(!(this instanceof RedisBackend)){
		return new RedisBackend(port, hostname, opts);
	}

	opts = opts || {};
	port = port || 6379;
	hostname = hostname || 'localhost';

	this.redis = redis.createClient(port, hostname, opts);
	this.publish = redis.createClient(port, hostname, opts);

	this.prefix = opts.prefix + '';

	this.baseKey = baseKey(this.prefix);
}
323700
def set_snmp(snmp_mode, snmp_alerts)
      new_action = { 'Mode' => snmp_mode, 'AlertsEnabled' => snmp_alerts }
      response = rest_patch('/redfish/v1/Managers/1/SnmpService/', body: new_action)
      response_handler(response)
      true
    end