Initializes a local hardware dut
425548
def init_generic_serial_dut(contextlist, conf, index, args):
    
    port = conf['serial_port']
    baudrate = (args.baudrate if args.baudrate else conf.get(
        "application", {}).get("baudrate", 115200))
    serial_config = {}
    if args.serial_rtscts:
        serial_config["serial_rtscts"] = args.serial_rtscts
    elif args.serial_xonxoff:
        serial_config["serial_xonxoff"] = args.serial_xonxoff

    if args.serial_timeout:
        serial_config["serial_timeout"] = args.serial_timeout

    ch_mode_config = {}
    if args.serial_ch_size > 0:
        ch_mode_config["ch_mode"] = True
        ch_mode_config["ch_mode_chunk_size"] = args.serial_ch_size
    elif args.serial_ch_size is 0:
        ch_mode_config["ch_mode"] = False

    if args.ch_mode_ch_delay:
        ch_mode_config["ch_mode_ch_delay"] = args.ch_mode_ch_delay
    dut = DutSerial(name="D%d" % index, port=port, baudrate=baudrate,
                    config=conf, ch_mode_config=ch_mode_config,
                    serial_config=serial_config, params=args)
    dut.index = index

    dut.platform = conf.get("platform_name", "serial")

    msg = 'Use device in serial port {} as D{}'
    contextlist.logger.info(msg.format(port,
                                       index))

    contextlist.duts.append(dut)
    contextlist.dutinformations.append(dut.get_info())
334199
function init(_pluginInterface) {
    pi = _pluginInterface;
    localStorage = pi.localStorage;
    log = pi.log;
    ipv4.setNetCallbackFunctions(
        function(net, newmac, newip) {
            for (const callbacks of Object.values(NetCallbacks)) {
                if (callbacks.onMacFoundCallback != undefined) {
                    callbacks.onMacFoundCallback(net, newmac, newip);
                }
            }
            // NetCallbacks[plugin_name].onNewIDFoundCallback(newid,newip);
        }
        , function(net, lostmac, lostip) {
            for (const callbacks of Object.values(NetCallbacks)) {
                if (callbacks.onMacLostCallback != undefined) {
                    callbacks.onMacLostCallback(net, lostmac, lostip);
                }
            }
            // NetCallbacks[plugin_name].onIPAddressLostCallback(id,lostip);
        }
        , function(net, mac, oldip, newip) {
            for (const callbacks of Object.values(NetCallbacks)) {
                if (callbacks.onIPChangedCallback != undefined) {
                    callbacks.onIPChangedCallback(net, mac, oldip, newip);
                }
            }
            // NetCallbacks[plugin_name].onIPAddressChangedCallback(id,oldip,newip);
        }
    );

    // Periodical publish test
    /*setInterval(()=>{
        pi.server.publish(
            'HelloTopic'
            ,{desc:'Hello desc'});
    },15000);*/
}
1371695
@Override void init0() {
    _sums = MemoryManager.malloc8d(_nbin);
    _ssqs = MemoryManager.malloc8d(_nbin);
  }
952835
public static void initJNI()
  {
    if (_isInitJNI.getAndSet(true)) {
      return;
    }

    // order matters because of static init and license checking
    FilesystemPath jniFilePath = JniFilePath.create();

    if (jniFilePath != null) {
      DEFAULT_SCHEME_MAP.put("file", jniFilePath);

      SchemeMap localMap = _localSchemeMap.get();
      if (localMap != null)
        localMap.put("file", jniFilePath);

      localMap = _localSchemeMap.get(ClassLoader.getSystemClassLoader());
      if (localMap != null)
        localMap.put("file", jniFilePath);

      VfsOld.PWD = jniFilePath;
      VfsOld.setPwd(jniFilePath);
    }
  }
1057980
function initialize() {
    if (global.isVinn) {
      tr.isVinn = true;
    } else if (global.process && global.process.versions.node) {
      tr.isNode = true;
    } else {
      tr.isVinn = false;
      tr.isNode = false;
      tr.doc = document;

      tr.isMac = /Mac/.test(navigator.platform);
      tr.isWindows = /Win/.test(navigator.platform);
      tr.isChromeOS = /CrOS/.test(navigator.userAgent);
      tr.isLinux = /Linux/.test(navigator.userAgent);
    }
    tr.isHeadless = tr.isVinn || tr.isNode;
  }
644903
def initialize():
        """"""
        _WindowsCSBI._define_csbi()
        _WindowsCSBI.HANDLE_STDERR = _WindowsCSBI.HANDLE_STDERR or _WindowsCSBI.WINDLL.kernel32.GetStdHandle(-12)
        _WindowsCSBI.HANDLE_STDOUT = _WindowsCSBI.HANDLE_STDOUT or _WindowsCSBI.WINDLL.kernel32.GetStdHandle(-11)
        if _WindowsCSBI.WINDLL.kernel32.GetConsoleScreenBufferInfo.argtypes:
            return

        _WindowsCSBI.WINDLL.kernel32.GetStdHandle.argtypes = [ctypes.wintypes.DWORD]
        _WindowsCSBI.WINDLL.kernel32.GetStdHandle.restype = ctypes.wintypes.HANDLE
        _WindowsCSBI.WINDLL.kernel32.GetConsoleScreenBufferInfo.restype = ctypes.wintypes.BOOL
        _WindowsCSBI.WINDLL.kernel32.GetConsoleScreenBufferInfo.argtypes = [
            ctypes.wintypes.HANDLE, ctypes.POINTER(_WindowsCSBI.CSBI)
        ]
619980
def InternalInit(self):
    """"""
    self.cid = UsbHidTransport.U2FHID_BROADCAST_CID
    nonce = bytearray(os.urandom(8))
    r = self.InternalExchange(UsbHidTransport.U2FHID_INIT, nonce)
    if len(r) < 17:
      raise errors.HidError('unexpected init reply len')
    if r[0:8] != nonce:
      raise errors.HidError('nonce mismatch')
    self.cid = bytearray(r[8:12])

    self.u2fhid_version = r[12]
203520
function init (func) {
    func = ensureFunc(func);
    cache = undefined;
    deps = parseDepsFromFunc(func);
  }
1166582
def init_module(filesystem):
    """"""
    # pylint: disable=protected-access
    FakePath.filesystem = filesystem
    FakePathlibModule.PureWindowsPath._flavour = _FakeWindowsFlavour(
        filesystem)
    FakePathlibModule.PurePosixPath._flavour = _FakePosixFlavour(filesystem)
506089
def cli(env, identifier, postinstall, key):
    """"""

    hardware = SoftLayer.HardwareManager(env.client)
    hardware_id = helpers.resolve_id(hardware.resolve_ids,
                                     identifier,
                                     'hardware')
    key_list = []
    if key:
        for single_key in key:
            resolver = SoftLayer.SshKeyManager(env.client).resolve_ids
            key_id = helpers.resolve_id(resolver, single_key, 'SshKey')
            key_list.append(key_id)
    if not (env.skip_confirmations or formatting.no_going_back(hardware_id)):
        raise exceptions.CLIAbort('Aborted')

    hardware.reload(hardware_id, postinstall, key_list)
481342
private void initAST() {
    jsRoot = IR.root();
    externsRoot = IR.root();
    externAndJsRoot = IR.root(externsRoot, jsRoot);
  }
897243
def init(self, initial):
        
        if initial <= 0:
            return False
        step = initial // BLOCK_SIZE
        with self._lock:
            init = self._atomic_long.compare_and_set(0, step + 1).result()
            if init:
                self._local = step
                self._residue = (initial % BLOCK_SIZE) + 1
            return init
210257
public void init(APUtils utils) throws DuzztInitializationException {
		URL url = GenerateEDSLProcessor.class.getResource(ST_RESOURCE_NAME);
		
		this.sourceGenGroup = new STGroupFile(
				url,
				ST_ENCODING,
				ST_DELIM_START_CHAR,
				ST_DELIM_STOP_CHAR);
		
		sourceGenGroup.setListener(new ReporterDiagnosticListener(utils.getReporter()));
		
		sourceGenGroup.load();
		if(!sourceGenGroup.isDefined(ST_MAIN_TEMPLATE_NAME)) {
			sourceGenGroup = null;
			throw new DuzztInitializationException("Could not find main template '"
					+ ST_MAIN_TEMPLATE_NAME + "' in template group file " + url.toString());
		}

		this.isJava9OrNewer = isJava9OrNewer(utils.getProcessingEnv().getSourceVersion());
	}
86891
def initialize_vthunder(a10_cfg, device_cfg, client):
    """"""

    vth = a10_cfg.get_vthunder_config()
    initialize_interfaces(vth, device_cfg, client)
    initialize_dns(vth, device_cfg, client)
    initialize_licensing(vth, device_cfg, client)
    initialize_sflow(vth, device_cfg, client)
1171530
private void initializeDefaults() {
        String keyStoreType = getProperty(Constants.SSLPROP_KEY_STORE_TYPE);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, "keyStoreType: " + keyStoreType);

        if (keyStoreType == null && getProperty(Constants.SYSTEM_SSLPROP_KEY_STORE_TYPE) == null) {
            setProperty(Constants.SSLPROP_KEY_STORE_FILE_BASED, Constants.TRUE);
            setProperty(Constants.SSLPROP_KEY_STORE_TYPE, Constants.KEYSTORE_TYPE_PKCS12);
            keyStoreType = Constants.KEYSTORE_TYPE_PKCS12;
        } else {
            if (keyStoreType != null &&
                !keyStoreType.equals(Constants.KEYSTORE_TYPE_JKS) &&
                !keyStoreType.equals(Constants.KEYSTORE_TYPE_JCEKS) &&
                !keyStoreType.equals(Constants.KEYSTORE_TYPE_PKCS12)) {
                setProperty(Constants.SSLPROP_KEY_STORE_FILE_BASED, Constants.FALSE);
            } else {
                setProperty(Constants.SSLPROP_KEY_STORE_FILE_BASED, Constants.TRUE);
            }
        }

        String trustStoreType = getProperty(Constants.SSLPROP_TRUST_STORE_TYPE);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, "trustStoreType: " + trustStoreType);

        if (trustStoreType == null && getProperty(Constants.SYSTEM_SSLPROP_TRUST_STORE_TYPE) == null) {
            setProperty(Constants.SSLPROP_TRUST_STORE_FILE_BASED, Constants.TRUE);
            setProperty(Constants.SSLPROP_TRUST_STORE_TYPE, Constants.KEYSTORE_TYPE_PKCS12);
            trustStoreType = Constants.KEYSTORE_TYPE_PKCS12;
        } else {
            if (trustStoreType != null &&
                !trustStoreType.equals(Constants.KEYSTORE_TYPE_JKS) &&
                !trustStoreType.equals(Constants.KEYSTORE_TYPE_JCEKS) &&
                !trustStoreType.equals(Constants.KEYSTORE_TYPE_PKCS12)) {
                setProperty(Constants.SSLPROP_TRUST_STORE_FILE_BASED, Constants.FALSE);
            } else {
                setProperty(Constants.SSLPROP_TRUST_STORE_FILE_BASED, Constants.TRUE);
            }
        }

        JSSEProvider defaultProvider = JSSEProviderFactory.getInstance();

        if (getProperty(Constants.SSLPROP_KEY_MANAGER) == null)
            setProperty(Constants.SSLPROP_KEY_MANAGER, JSSEProviderFactory.getKeyManagerFactoryAlgorithm());

        if (getProperty(Constants.SSLPROP_KEY_STORE_PROVIDER) == null
            && null != defaultProvider.getKeyStoreProvider())
            setProperty(Constants.SSLPROP_KEY_STORE_PROVIDER, defaultProvider.getKeyStoreProvider());

        if (getProperty(Constants.SSLPROP_PROTOCOL) == null)
            setProperty(Constants.SSLPROP_PROTOCOL, defaultProvider.getDefaultProtocol());

        if (getProperty(Constants.SSLPROP_CLIENT_AUTHENTICATION) == null)
            setProperty(Constants.SSLPROP_CLIENT_AUTHENTICATION, Constants.FALSE);

        if (getProperty(Constants.SSLPROP_CONTEXT_PROVIDER) == null)
            setProperty(Constants.SSLPROP_CONTEXT_PROVIDER, defaultProvider.getContextProvider());

        if (getProperty(Constants.SSLPROP_SECURITY_LEVEL) == null)
            setProperty(Constants.SSLPROP_SECURITY_LEVEL, Constants.SECURITY_LEVEL_HIGH);

        if (getProperty(Constants.SSLPROP_TRUST_MANAGER) == null)
            setProperty(Constants.SSLPROP_TRUST_MANAGER, JSSEProviderFactory.getTrustManagerFactoryAlgorithm());

        if (getProperty(Constants.SSLPROP_TRUST_STORE_PROVIDER) == null
            && null != defaultProvider.getKeyStoreProvider())
            setProperty(Constants.SSLPROP_TRUST_STORE_PROVIDER, defaultProvider.getKeyStoreProvider());

        if (getProperty(Constants.SSLPROP_VALIDATION_ENABLED) == null)
            setProperty(Constants.SSLPROP_VALIDATION_ENABLED, Constants.FALSE);

        if (getProperty(Constants.SSLPROP_TOKEN_ENABLED) == null)
            setProperty(Constants.SSLPROP_TOKEN_ENABLED, Constants.FALSE);

        String keyStore = getProperty(Constants.SSLPROP_KEY_STORE);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "keyStore: " + keyStore);
        }
        String keyStoreName = getProperty(Constants.SSLPROP_KEY_STORE_NAME);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "keyStoreName: " + keyStoreName);
        }
        String keyStorePassword = getProperty(Constants.SSLPROP_KEY_STORE_PASSWORD);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, "keyStorePassword: " + SSLConfigManager.mask(keyStorePassword));

        String trustStore = getProperty(Constants.SSLPROP_TRUST_STORE);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "trustStore: " + trustStore);
        }
        String trustStoreName = getProperty(Constants.SSLPROP_TRUST_STORE_NAME);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "trustStoreName: " + trustStoreName);
        }
        String trustStorePassword = getProperty(Constants.SSLPROP_TRUST_STORE_PASSWORD);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, "trustStorePassword: " + SSLConfigManager.mask(trustStorePassword));

        // When only a trust store is specified, use it as the key store as well.
        if (keyStore == null && trustStore != null && trustStorePassword != null && trustStoreType != null) {
            setProperty(Constants.SSLPROP_KEY_STORE, trustStore);
            setProperty(Constants.SSLPROP_KEY_STORE_NAME, trustStoreName);
            setProperty(Constants.SSLPROP_KEY_STORE_PASSWORD, trustStorePassword);
            setProperty(Constants.SSLPROP_KEY_STORE_TYPE, trustStoreType);
        }
        // When only a key store is specified, use it as the trust store as well.
        else if (trustStore == null && keyStore != null && keyStorePassword != null && keyStoreType != null) {
            setProperty(Constants.SSLPROP_TRUST_STORE, keyStore);
            setProperty(Constants.SSLPROP_TRUST_STORE_NAME, keyStoreName);
            setProperty(Constants.SSLPROP_TRUST_STORE_PASSWORD, keyStorePassword);
            setProperty(Constants.SSLPROP_TRUST_STORE_TYPE, keyStoreType);
        }
    }
939440
def init(i): # pragma: no cover
    

    global cfg, work, initialized, paths_repos, type_long, string_io

    if initialized:
       return {'return':0}

    # Split version
    cfg['version']=__version__.split('.')

    # Default URL. FIXME: should be formed from wfe_host and wfe_port when they are known.
    # cfg['wfe_url_prefix'] = 'http://%s:%s/web?' % (cfg['default_host'], cfg['default_port'])

    # Check long/int types
    try:
       x=long
    except Exception as e:
       type_long=int
    else:
       type_long=long

    # Import StringIO
    if sys.version_info[0]>2:
       import io
       string_io=io.StringIO
    else:
       from StringIO import StringIO
       string_io=StringIO

    # Check where are repos (to keep compatibility with past CK < V1.5)
    p=''

    import inspect
    pxx=os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
    px=os.path.dirname(pxx)
    py=os.path.join(pxx, cfg['subdir_default_repo'])
    if os.path.isdir(py):
       p=py

    if p=='':
       from distutils.sysconfig import get_python_lib
       px=get_python_lib()
       py=os.path.join(px, cfg['kernel_dir'], cfg['subdir_default_repo'])
       if os.path.isdir(py):
          p=py

    if p=='':
       import site
       for px in site.getsitepackages():
           py=os.path.join(px, cfg['kernel_dir'],cfg['subdir_default_repo'])
           if os.path.isdir(py):
              p=py
              break

    # Check CK_ROOT environment variable
    s=os.environ.get(cfg['env_key_root'],'').strip()
    if s!='':
       work['env_root']=os.path.realpath(s)

       for px in cfg['kernel_dirs']:
           py=os.path.join(work['env_root'], px, cfg['subdir_default_repo'])
           if os.path.isdir(py):
              p=py
              break
    elif px!='':
      work['env_root']=px

    if p=='':
       return {'return':1, 'error':'Internal CK error (can\'t find default repo) - please report to authors'}

    # Check default repo
    work['dir_default_repo']=p
    work['dir_default_repo_path']=os.path.join(work['dir_default_repo'], cfg['module_repo_name'], cfg['repo_name_default'])
    work['dir_default_kernel']=os.path.join(work['dir_default_repo'], cfg['subdir_kernel'])
    work['dir_default_cfg']=os.path.join(work['dir_default_kernel'], cfg['subdir_kernel_default'], cfg['subdir_ck_ext'], cfg['file_meta'])

    work['dir_work_repo']=work['dir_default_repo']
    work['dir_work_repo_path']=work['dir_default_repo_path']
    work['dir_work_kernel']=work['dir_default_kernel']
    work['dir_work_cfg']=work['dir_default_cfg']

    work['repo_name_work']=cfg['repo_name_default']
    work['repo_uid_work']=cfg['repo_uid_default']

    # Check external repos
    rps=os.environ.get(cfg['env_key_repos'],'').strip()
    if rps=='': 
       # Get home user directory
       from os.path import expanduser
       home = expanduser("~")

       # In the original version, if path to repos was not defined, I was using CK path,
       # however, when installed as root, it will fail
       # rps=os.path.join(work['env_root'],cfg['subdir_default_repos'])
       # hence I changed to <user home dir>/CK
       rps=os.path.join(home, cfg['user_home_dir_ext'])
       if not os.path.isdir(rps):
          os.makedirs(rps)

    work['dir_repos']=rps

    # Check CK_LOCAL_REPO environment variable - if doesn't exist, create in user space
    s=os.environ.get(cfg['env_key_local_repo'],'').strip()

    if s=='':
       # Set up local default repository
       s=os.path.join(rps, cfg['repo_name_local'])
       if not os.path.isdir(s):
          os.makedirs(s)

          # Create description
          rq=save_json_to_file({'json_file':os.path.join(s,cfg['repo_file']),
                                'dict':{'data_alias':cfg['repo_name_local'],
                                        'data_uoa':cfg['repo_name_local'],
                                        'data_name':cfg['repo_name_local'],
                                        'data_uid':cfg['repo_uid_local']},
                                'sort_keys':'yes'})
          if rq['return']>0: return rq

    if s!='':
       work['local_kernel_uoa']=cfg['subdir_kernel_default']
       x=os.environ.get(cfg['env_key_local_kernel_uoa'],'').strip()
       if x!='': work['local_kernel_uoa']=x

       work['dir_local_repo']=os.path.realpath(s)
       work['dir_local_repo_path']=os.path.join(work['dir_local_repo'], cfg['module_repo_name'], cfg['repo_name_local'])
       work['dir_local_kernel']=os.path.join(work['dir_local_repo'], cfg['subdir_kernel'])
       work['dir_local_cfg']=os.path.join(work['dir_local_kernel'], work['local_kernel_uoa'], cfg['subdir_ck_ext'], cfg['file_meta'])

       # Update work repo!
       work['dir_work_repo']=work['dir_local_repo']
       work['dir_work_repo_path']=work['dir_local_repo_path']
       work['dir_work_kernel']=work['dir_local_kernel']
       work['dir_work_cfg']=work['dir_local_cfg']

       work['repo_name_work']=cfg['repo_name_local']
       work['repo_uid_work']=cfg['repo_uid_local']

       paths_repos.append({'path':work['dir_local_repo'],
                           'repo_uoa':cfg['repo_name_local'],
                           'repo_uid':cfg['repo_uid_local'],
                           'repo_alias':cfg['repo_name_local']})

    paths_repos.append({'path':work['dir_default_repo'],
                        'repo_uoa':cfg['repo_name_default'],
                        'repo_uid':cfg['repo_uid_default'],
                        'repo_alias':cfg['repo_name_default']})

    # Prepare repo cache
    work['dir_cache_repo_uoa']=os.path.join(work['dir_work_repo'],cfg['file_cache_repo_uoa'])
    work['dir_cache_repo_info']=os.path.join(work['dir_work_repo'],cfg['file_cache_repo_info'])

    # Check if first time and then copy local cache files (with remote-ck)
    if not os.path.isfile(work['dir_cache_repo_uoa']) and not os.path.isfile(work['dir_cache_repo_info']):
       rx=load_text_file({'text_file':os.path.join(work['dir_default_repo'],cfg['file_cache_repo_uoa'])})
       if rx['return']>0: return rx
       x1=rx['string']

       rx=load_text_file({'text_file':os.path.join(work['dir_default_repo'],cfg['file_cache_repo_info'])})
       if rx['return']>0: return rx
       x2=rx['string']

       rx=save_text_file({'text_file':work['dir_cache_repo_info'], 'string':x2})
       if rx['return']>0: return rx

       rx=save_text_file({'text_file':work['dir_cache_repo_uoa'], 'string':x1})
       if rx['return']>0: return rx

    # Check if local configuration exists, and if not, create it
    if not os.path.isfile(work['dir_local_cfg']):
       # Create empty local configuration
       rx=add({'repo_uoa':cfg['repo_name_local'],
               'module_uoa':cfg['subdir_kernel'],
               'data_uoa':work['local_kernel_uoa']})
       if rx['return']>0:
          return {'return':rx['return'],
                  'error':'can\'t create local configuration entry'}

    # Read kernel configuration (if exists)
    if os.path.isfile(work['dir_work_cfg']):
       r=load_json_file({'json_file':work['dir_work_cfg']})
       if r['return']>0: return r
       cfg1=r['dict']

       # Update cfg
       r=merge_dicts({'dict1':cfg, 'dict2':cfg1})
       if r['return']>0: return r

    initialized=True

    return {'return':0}
333059
private void init() {
        generalHuffsize();
        generalHuffcode();

        int i = 0, j = 0;
        for (;;) {
            i++;

            if (i > 16) {
                break;
            }

            if (L[i] == 0) {
                maxcode[i] = -1;
                continue;
            } else {
                valptr[i] = j;
                mincode[i] = huffcode[j];
                j = j + L[i] - 1;
                maxcode[i] = huffcode[j];
                j++;
            }
        }

        maxcode[17] = 0xFFFFFF;
    }