Initialize NoneBot instance.

    This function must be called at the very beginning of code,
    otherwise the get_bot() function will return None and nothing
    is gonna work properly.

    :param config_object: configuration object
186866
def init(config_object: Optional[Any] = None) -> None:
    
    global _bot
    _bot = NoneBot(config_object)

    if _bot.config.DEBUG:
        logger.setLevel(logging.DEBUG)
    else:
        logger.setLevel(logging.INFO)

    _bot.server_app.before_serving(_start_scheduler)
730962
def init_process(self) -> None:
        
        default_loop = asyncio.get_event_loop()
        if default_loop.is_running():
            default_loop.close()
            self.loop = asyncio.new_event_loop()
            asyncio.set_event_loop(self.loop)
        else:
            self.loop = default_loop
        super().init_process()
600422
def tracer_config(__init__, app, args, kwargs):
    
    __init__(*args, **kwargs)

    tracing = app.settings.get('opentracing_tracing')
    tracer_callable = app.settings.get('opentracing_tracer_callable')
    tracer_parameters = app.settings.get('opentracing_tracer_parameters', {})

    if tracer_callable is not None:
        if not callable(tracer_callable):
            tracer_callable = _get_callable_from_name(tracer_callable)

        tracer = tracer_callable(**tracer_parameters)
        tracing = TornadoTracing(tracer)

    if tracing is None:
        tracing = TornadoTracing()  # fallback to the global tracer

    app.settings['opentracing_tracing'] = tracing

    tracing._trace_all = app.settings.get('opentracing_trace_all',
                                          DEFAULT_TRACE_ALL)
    tracing._trace_client = app.settings.get('opentracing_trace_client',
                                             DEFAULT_TRACE_CLIENT)
    tracing._start_span_cb = app.settings.get('opentracing_start_span_cb',
                                              None)

    httpclient._set_tracing_enabled(tracing._trace_client)
    if tracing._trace_client:
        httpclient._set_tracing_info(tracing._tracer_obj,
                                     tracing._start_span_cb)
576157
function INIT(config) {
  if (__init) return;

  CONF = config

  if (!! CONF.redis) {
    // TODO: avoid this hassle if https://github.com/LearnBoost/kue/issues/54 
    //       ever gets fixed
    reds.createClient = function() {
      var client = redis.createClient(CONF.redis.port, CONF.redis.host)
      client.auth(CONF.redis.pass)
      return client
    }

    kue.redis.createClient = reds.createClient
  }

  JOBS = kue.createQueue()
  RED = JOBS.client

  JOBS.promote()

  __init = true
}
1093805
def init(*args, **kwargs):
    
    global _initial_client
    client = Client(*args, **kwargs)
    Hub.current.bind_client(client)
    rv = _InitGuard(client)
    if client is not None:
        _initial_client = weakref.ref(client)
    return rv
1178815
def __init(self):
        
        params = {
            "f" : "json"
        }
        json_dict = self._get(url=self._url, param_dict=params,
                                 securityHandler=self._securityHandler,
                                 proxy_url=self._proxy_url,
                                 proxy_port=self._proxy_port)
        attributes = [attr for attr in dir(self)
                      if not attr.startswith('__') and \
                      not attr.startswith('_')]
        for k,v in json_dict.items():
            if k in attributes:
                setattr(self, "_"+ k, json_dict[k])
            else:
                print( k, " - attribute not implemented in RouteNetworkLayer.")
            del k,v
68158
def create(cls, config_file=None):
        
        if cls.instance is None:
            cls.instance = cls(config_file)

            # Load config file, possibly overwriting the defaults
            cls.instance.load_ini()

        if config_file and config_file != cls.instance.config_file:
            raise RuntimeError("Configuration initialized a second time with a different file!")

        return cls.instance
987223
def init(conf):
    

    logger = logging.getLogger(__name__)

    # Initialize mimetypes library
    mimetypes.init([pkg_resources.resource_filename('ehforwarderbot', 'mimetypes')])

    # Initialize all channels
    # (Load libraries and modules and init them)

    for i in conf['slave_channels']:
        logger.log(99, "\x1b[0;37;46m %s \x1b[0m", _("Initializing slave {}...").format(i))

        cls = utils.locate_module(i, 'slave')
        telemetry_set_metadata({i: cls.__version__})
        instance_id = i.split('#', 1)[1:]
        instance_id = (instance_id and instance_id[0]) or None
        coordinator.add_channel(cls(instance_id=instance_id))

        logger.log(99, "\x1b[0;37;42m %s \x1b[0m",
                   _("Slave channel {name} ({id}) # {instance_id} is initialized.")
                   .format(name=cls.channel_name, id=cls.channel_id,
                           instance_id=instance_id or _("Default profile")))

    logger.log(99, "\x1b[0;37;46m %s \x1b[0m",
               _("Initializing master {}...").format(conf['master_channel']))
    instance_id = conf['master_channel'].split('#', 1)[1:]
    instance_id = (instance_id and instance_id[0]) or None
    module = utils.locate_module(conf['master_channel'], 'master')
    coordinator.add_channel(module(instance_id=instance_id))
    telemetry_set_metadata({conf['master_channel']: module.__version__})
    logger.log(99, "\x1b[0;37;42m %s \x1b[0m",
               _("Master channel {name} ({id}) # {instance_id} is initialized.")
               .format(name=coordinator.master.channel_name,
                       id=coordinator.master.channel_id,
                       instance_id=instance_id or _("Default profile")))

    logger.log(99, "\x1b[1;37;42m %s \x1b[0m", _("All channels initialized."))
    for i in conf['middlewares']:
        logger.log(99, "\x1b[0;37;46m %s \x1b[0m", _("Initializing middleware {}...").format(i))
        cls = utils.locate_module(i, 'middleware')
        telemetry_set_metadata({i: cls.__version__})

        instance_id = i.split('#', 1)[1:]
        instance_id = (instance_id and instance_id[0]) or None
        coordinator.add_middleware(cls(instance_id=instance_id))
        logger.log(99, "\x1b[0;37;42m %s \x1b[0m",
                   _("Middleware {name} ({id}) # {instance_id} is initialized.")
                   .format(name=cls.middleware_name, id=cls.middleware_id,
                           instance_id=instance_id or _("Default profile")))

    logger.log(99, "\x1b[1;37;42m %s \x1b[0m", _("All middlewares are initialized."))

    coordinator.master_thread = threading.Thread(target=coordinator.master.poll)
    coordinator.slave_threads = {key: threading.Thread(target=coordinator.slaves[key].poll)
                                 for key in coordinator.slaves}
1215651
def init_config(args):
    
    os.environ["AUTOMLBOARD_LOGDIR"] = args.logdir
    os.environ["AUTOMLBOARD_LOGLEVEL"] = args.log_level
    os.environ["AUTOMLBOARD_RELOAD_INTERVAL"] = str(args.reload_interval)

    if args.db:
        try:
            db_address_reg = re.compile(r"(.*)://(.*):(.*)@(.*):(.*)/(.*)")
            match = re.match(db_address_reg, args.db_address)
            os.environ["AUTOMLBOARD_DB_ENGINE"] = match.group(1)
            os.environ["AUTOMLBOARD_DB_USER"] = match.group(2)
            os.environ["AUTOMLBOARD_DB_PASSWORD"] = match.group(3)
            os.environ["AUTOMLBOARD_DB_HOST"] = match.group(4)
            os.environ["AUTOMLBOARD_DB_PORT"] = match.group(5)
            os.environ["AUTOMLBOARD_DB_NAME"] = match.group(6)
            logger.info("Using %s as the database backend." % match.group(1))
        except BaseException as e:
            raise DatabaseError(e)
    else:
        logger.info("Using sqlite3 as the database backend, "
                    "information will be stored in automlboard.db")

    os.environ.setdefault("DJANGO_SETTINGS_MODULE",
                          "ray.tune.automlboard.settings")
    django.setup()
    command = [os.path.join(root_path, "manage.py"), "migrate", "--run-syncdb"]
    execute_from_command_line(command)
1119716
def _init(self, *args, **kwargs):
        
        self._init_attr('_deps', None)

        self._init_attr('_ban_optimize', False)
        self._init_attr('_engine', None)
        self._init_attr('_Expr__execution', None)

        self._init_attr('_need_cache', False)
        self._init_attr('_mem_cache', False)

        if '_id' not in kwargs:
            kwargs['_id'] = new_id()

        super(Expr, self)._init(*args, **kwargs)
1276256
def configure_app(app, config=None, config_obj=None):
    
    app.config.from_object(config_obj or BaseConfig)
    if config is not None:
        app.config.from_pyfile(config)
484323
def get_instance(in_memory=False, config_path=None, config_name=None):
  
  global __conf

  if __conf is None:
    __conf = Configuration(in_memory=in_memory, custom_cfg_path=config_path, config_name=config_name)

  return __conf
1109078
def populate(self, installed_bots=None):
        
        if self.ready:
            return

        # populate() might be called by two threads in parallel on servers
        # that create threads before initializing the WSGI callable.
        with self._lock:
            if self.ready:
                return

            # An RLock prevents other threads from entering this section. The
            # compare and set operation below is atomic.
            if self.loading:
                # Prevent re-entrant calls to avoid running AppConfig.ready()
                # methods twice.
                raise RuntimeError("populate() isn't re-entrant")
            self.loading = True

            # Phase 1: Initialize bots
            for entry in installed_bots or {}:
                if isinstance(entry, Bot):
                    cls = entry
                    entry = '.'.join([cls.__module__, cls.__name__])
                bot_reg = BotRegistry.create(entry)
                if bot_reg.label in self.bots:
                    raise ImproperlyConfigured(
                        "Bot labels aren't unique, "
                        "duplicates: %s" % bot_reg.label)

                self.bots[bot_reg.label] = bot_reg
                bot_reg.bots = self

            # Check for duplicate bot names.
            counts = Counter(
                bot_reg.name for bot_reg in self.bots.values())
            duplicates = [
                name for name, count in counts.most_common() if count > 1]
            if duplicates:
                raise ImproperlyConfigured(
                    "Bot names aren't unique, "
                    "duplicates: %s" % ", ".join(duplicates))

            self.bots_ready = True

            # Phase 2: import config files
            for bot in self.bots.values():
                bot.import_configs()

            self.configs_ready = True

            self.ready = True
732183
def singleton_init_by(init_fn=None):
    

    if not init_fn:
        def wrap_init(origin_init):
            return origin_init
    else:
        def wrap_init(origin_init):
            def __init__(self):
                origin_init(self)
                init_fn(self)

            return __init__

    def inner(cls_def: type):
        if not hasattr(cls_def, '__instancecheck__') or isinstance(cls_def.__instancecheck__,
                                                                   (types.BuiltinMethodType, _slot_wrapper)):
            def __instancecheck__(self, instance):
                return instance is self

            cls_def.__instancecheck__ = __instancecheck__

        _origin_init = cls_def.__init__
        cls_def.__init__ = wrap_init(_origin_init)

        return cls_def()

    return inner
1151930
def initialize(config):
    

    # Determine the client class to use
    if 'redis_client' in config:
        client = utils.find_entrypoint('turnstile.redis_client',
                                       config['redis_client'], required=True)
    else:
        client = redis.StrictRedis

    # Extract relevant connection information from the configuration
    kwargs = {}
    for cfg_var, type_ in REDIS_CONFIGS.items():
        if cfg_var in config:
            kwargs[cfg_var] = type_(config[cfg_var])

    # Make sure we have at a minimum the hostname
    if 'host' not in kwargs and 'unix_socket_path' not in kwargs:
        raise redis.ConnectionError("No host specified for redis database")

    # Look up the connection pool configuration
    cpool_class = None
    cpool = {}
    extra_kwargs = {}
    for key, value in config.items():
        if key.startswith('connection_pool.'):
            _dummy, _sep, varname = key.partition('.')
            if varname == 'connection_class':
                cpool[varname] = utils.find_entrypoint(
                    'turnstile.connection_class', value, required=True)
            elif varname == 'max_connections':
                cpool[varname] = int(value)
            elif varname == 'parser_class':
                cpool[varname] = utils.find_entrypoint(
                    'turnstile.parser_class', value, required=True)
            else:
                cpool[varname] = value
        elif key not in REDIS_CONFIGS and key not in REDIS_EXCLUDES:
            extra_kwargs[key] = value
    if cpool:
        cpool_class = redis.ConnectionPool

    # Use custom connection pool class if requested...
    if 'connection_pool' in config:
        cpool_class = utils.find_entrypoint('turnstile.connection_pool',
                                            config['connection_pool'],
                                            required=True)

    # If we're using a connection pool, we'll need to pass the keyword
    # arguments to that instead of to redis
    if cpool_class:
        cpool.update(kwargs)

        # Use a custom connection class?
        if 'connection_class' not in cpool:
            if 'unix_socket_path' in cpool:
                if 'host' in cpool:
                    del cpool['host']
                if 'port' in cpool:
                    del cpool['port']

                cpool['path'] = cpool['unix_socket_path']
                del cpool['unix_socket_path']

                cpool['connection_class'] = redis.UnixDomainSocketConnection
            else:
                cpool['connection_class'] = redis.Connection

        # Build the connection pool to use and set up to pass it into
        # the redis constructor...
        kwargs = dict(connection_pool=cpool_class(**cpool))

    # Build and return the database
    kwargs.update(extra_kwargs)
    return client(**kwargs)
253456
def __init(self):
        
        params = {
            "f" : "json",
        }
        json_dict = self._get(self._url, params,
                                 securityHandler=self._securityHandler,
                                 proxy_url=self._proxy_url,
                                 proxy_port=self._proxy_port)
        self._json_dict = json_dict
        self._json = json.dumps(self._json_dict)
        attributes = [attr for attr in dir(self)
                      if not attr.startswith('__') and \
                      not attr.startswith('_')]
        for k,v in json_dict.items():
            if k in attributes:
                if k == "versions" and json_dict[k]:
                    self._versions = []
                    for version in v:
                        self._versions.append(
                            Version(url=self._url + "/versions/%s" % version,
                                    securityHandler=self._securityHandler,
                                    proxy_url=self._proxy_url,
                                    proxy_port=self._proxy_port,
                                    initialize=False))
                elif k == "replicas" and json_dict[k]:
                    self._replicas = []
                    for version in v:
                        self._replicas.append(
                            Replica(url=self._url + "/replicas/%s" % version,
                                    securityHandler=self._securityHandler,
                                    proxy_url=self._proxy_url,
                                    proxy_port=self._proxy_port,
                                    initialize=False))
                else:
                    setattr(self, "_"+ k, v)
            else:
                print (k, " - attribute not implemented for GeoData Service")
121518
def get_config(self, config_name, require_ready=True):
        
        if require_ready:
            self.bots.check_configs_ready()
        else:
            self.bots.check_bots_ready()

        return self.configs.get(config_name.lower(), {})