Prepare a |NetCDFFile| object suitable for the given |IOSequence|
        object, when necessary, and pass the given arguments to its
        |NetCDFFile.log| method.
438040
def log(self, sequence, infoarray) -> None:
        """"""
        if isinstance(sequence, sequencetools.ModelSequence):
            descr = sequence.descr_model
        else:
            descr = 'node'
        if self._isolate:
            descr = '%s_%s' % (descr, sequence.descr_sequence)
            if ((infoarray is not None) and
                    (infoarray.info['type'] != 'unmodified')):
                descr = '%s_%s' % (descr, infoarray.info['type'])
        dirpath = sequence.dirpath_ext
        try:
            files = self.folders[dirpath]
        except KeyError:
            files: Dict[str, 'NetCDFFile'] = collections.OrderedDict()
            self.folders[dirpath] = files
        try:
            file_ = files[descr]
        except KeyError:
            file_ = NetCDFFile(
                name=descr,
                flatten=self._flatten,
                isolate=self._isolate,
                timeaxis=self._timeaxis,
                dirpath=dirpath)
            files[descr] = file_
        file_.log(sequence, infoarray)
463919
def _prepare_arguments(self, arguments):
        
        # Split arguments if given as string
        if arguments is not None:
            if isinstance(arguments, basestring):
                self.arguments = arguments.split()
            else:
                self.arguments = arguments
        # Otherwise properly decode command line arguments
        else:
            self.arguments = [arg.decode("utf-8") for arg in sys.argv[1:]]
1042593
@Override
  protected void preprocess() {
    final Logging log = getLogger(); // Could be subclass
    createStorage();

    ArrayDBIDs ids = DBIDUtil.ensureArray(relation.getDBIDs());

    if(log.isStatistics()) {
      log.statistics(new LongStatistic(this.getClass().getName() + ".k", k));
    }
    Duration duration = log.isStatistics() ? log.newDuration(this.getClass().getName() + ".precomputation-time").begin() : null;
    FiniteProgress progress = getLogger().isVerbose() ? new FiniteProgress("Materializing k nearest neighbors (k=" + k + ")", ids.size(), getLogger()) : null;
    // Try bulk
    List<? extends KNNList> kNNList = null;
    if(usebulk) {
      kNNList = knnQuery.getKNNForBulkDBIDs(ids, k);
      if(kNNList != null) {
        int i = 0;
        for(DBIDIter id = ids.iter(); id.valid(); id.advance(), i++) {
          storage.put(id, kNNList.get(i));
          log.incrementProcessed(progress);
        }
      }
    }
    else {
      final boolean ismetric = getDistanceQuery().getDistanceFunction().isMetric();
      for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) {
        if(ismetric && storage.get(iter) != null) {
          log.incrementProcessed(progress);
          continue; // Previously computed (duplicate point?)
        }
        KNNList knn = knnQuery.getKNNForDBID(iter, k);
        storage.put(iter, knn);
        if(ismetric) {
          for(DoubleDBIDListIter it = knn.iter(); it.valid() && it.doubleValue() == 0.; it.advance()) {
            storage.put(it, knn); // Reuse
          }
        }
        log.incrementProcessed(progress);
      }
    }
    log.ensureCompleted(progress);
    if(duration != null) {
      log.statistics(duration.end());
    }
  }
341927
function log() {
    var _console;

    if (LatticeLogs.failFast(LatticeLogs.LOG)) return;

    for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
      args[_key3] = arguments[_key3];
    }

    (_console = console).log.apply(_console, (0, _toConsumableArray2.default)(args.map(LatticeLogs.argMapper)));
  }
80264
public static void prepare(String fname) {

    if (!"Linux".equalsIgnoreCase(System.getProperty("os.name"))) {
      System.err.println("Linux system required for FailMon. Exiting...");
      System.exit(0);
    }

    System.setProperty("log4j.configuration", "conf/log4j.properties");
    PropertyConfigurator.configure("conf/log4j.properties");
    LOG = LogFactory.getLog("org.apache.hadoop.contrib.failmon");
    logInfo("********** FailMon started ***********");

    // read parseState file
    PersistentState.readState("conf/parsing.state");
    
    try {
      FileInputStream propFile = new FileInputStream(fname);
      fmProperties.load(propFile);
      propFile.close();
    } catch (FileNotFoundException e1) {
      e1.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
    ready = true;

    try {
      String sudo_prompt = "passwd_needed:";
      String echo_txt = "access_ok";
      
      Process p = Runtime.getRuntime().exec("sudo -S -p " + sudo_prompt + " echo " + echo_txt );
      InputStream inps = p.getInputStream();
      InputStream errs = p.getErrorStream();
      
      while (inps.available() < echo_txt.length() && errs.available() < sudo_prompt.length())
	Thread.sleep(100);

      byte [] buf;
      String s;
      
      if (inps.available() >= echo_txt.length()) {
        buf = new byte[inps.available()];
        inps.read(buf);
        s = new String(buf);
        if (s.startsWith(echo_txt)) {
          superuser = true;
	  logInfo("Superuser privileges found!");
	} else {
	  // no need to read errs
	  superuser = false;
	  logInfo("Superuser privileges not found.");
	}
      }
    } catch (IOException e) {
      e.printStackTrace();
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
302328
def _init_logging(verbose):
    """"""
    hdlr = logging.StreamHandler()
    hdlr.setFormatter(logging.Formatter(
        '%(asctime)s [%(levelname)s] [%(module)s] %(message)s'))
    LOG.addHandler(hdlr)
    if verbose:
        LOG.setLevel(logging.DEBUG)
        LOG.debug('Verbose output enabled.')
    else:
        LOG.setLevel(logging.INFO)
343370
def prepare(self, node):
        ''''''
        if isinstance(node, ast.Module):
            self.ctx.module = node
        elif isinstance(node, ast.FunctionDef):
            self.ctx.function = node

        for D in self.deps:
            d = D()
            d.attach(self.passmanager, self.ctx)
            result = d.run(node)
            setattr(self, uncamel(D.__name__), result)
443581
def append_logs_to_result_object(result_obj, result):
    
    logs = result.has_logs()
    result_obj["exec"]["logs"] = []
    if logs and result.logfiles:
        for log in logs:
            typ = None
            parts = log.split(os.sep)
            if "bench" in parts[len(parts) - 1]:
                typ = "framework"
            # elif "Dut" in parts[len(parts)-1]:
            #    typ = "dut"

            if typ is not None:
                name = parts[len(parts) - 1]
                try:
                    with open(log, "r") as file_name:
                        data = file_name.read()
                    dic = {"data": data, "name": name, "from": typ}
                    result_obj["exec"]["logs"].append(dic)
                except OSError:
                    pass
            else:
                continue
159948
def prepare(cls, value, length=0, position=0, is_last_data=True):
        
        hstruct = WriteLobHeader.header_struct
        lob_option_dataincluded = WriteLobHeader.LOB_OPTION_DATAINCLUDED if length > 0 else 0
        lob_option_lastdata = WriteLobHeader.LOB_OPTION_LASTDATA if is_last_data else 0
        options = lob_option_dataincluded | lob_option_lastdata
        pfield = hstruct.pack(cls.type_code, options, length, position)
        return pfield
210017
private synchronized void precomputeLogs(int len) {
    if(len <= ilogs.length) {
      return; // Probably done by another thread.
    }
    double[] logs = Arrays.copyOf(ilogs, len);
    for(int i = ilogs.length; i < len; i++) {
      logs[i] = FastMath.log1p(i);
    }
    this.ilogs = logs;
  }
1174356
def init_logger(root_dir, name="train.log"):
    
    os.makedirs(root_dir, exist_ok=True)
    log_formatter = logging.Formatter("%(message)s")
    logger = logging.getLogger(name)
    file_handler = logging.FileHandler("{0}/{1}".format(root_dir, name), mode='w')
    file_handler.setFormatter(log_formatter)
    logger.addHandler(file_handler)
    console_handler = logging.StreamHandler()
    console_handler.setFormatter(log_formatter)
    logger.addHandler(console_handler)
    logger.setLevel(logging.INFO)
    return logger
445184
def _init_ns2nt(rcntobj):
        """"""
        go2dcnt = rcntobj.go2dcnt
        ntobj = cx.namedtuple("NtD1", "D1 dcnt goobj")
        d0s = rcntobj.depth2goobjs[0]
        ns_nt = [(o.namespace, ntobj(D1="", dcnt=go2dcnt[o.id], goobj=o)) for o in d0s]
        return cx.OrderedDict(ns_nt)
171393
@Override
  protected void prepare(int flags) throws IOException {
    SysUtil.mkdirOrThrow(soDirectory);
    File lockFileName = new File(soDirectory, LOCK_FILE_NAME);
    FileLocker lock = FileLocker.lock(lockFileName);
    try {
      Log.v(TAG, "locked dso store " + soDirectory);
      if (refreshLocked(lock, flags, getDepsBlock())) {
        lock = null; // Lock transferred to syncer thread
      } else {
        Log.i(TAG, "dso store is up-to-date: " + soDirectory);
      }
    } finally {
      if (lock != null) {
        Log.v(TAG, "releasing dso store lock for " + soDirectory);
        lock.close();
      } else {
        Log.v(TAG, "not releasing dso store lock for "
            + soDirectory + " (syncer thread started)");
      }
    }
  }
701393
def prepare_runtime(self, runtime_dir, data):
        """"""
        # Copy over Python process runtime (resolwe.process).
        import resolwe.process as runtime_package

        src_dir = os.path.dirname(inspect.getsourcefile(runtime_package))
        dest_package_dir = os.path.join(runtime_dir, PYTHON_RUNTIME_DIRNAME, 'resolwe', 'process')
        shutil.copytree(src_dir, dest_package_dir)
        os.chmod(dest_package_dir, 0o755)

        # Write python source file.
        source = data.process.run.get('program', '')
        program_path = os.path.join(runtime_dir, PYTHON_PROGRAM_FILENAME)
        with open(program_path, 'w') as file:
            file.write(source)
        os.chmod(program_path, 0o755)

        # Write serialized inputs.
        inputs = copy.deepcopy(data.input)
        hydrate_input_references(inputs, data.process.input_schema)
        hydrate_input_uploads(inputs, data.process.input_schema)
        inputs_path = os.path.join(runtime_dir, PYTHON_INPUTS_FILENAME)

        # XXX: Skip serialization of LazyStorageJSON. We should support
        # LazyStorageJSON in Python processes on the new communication protocol
        def default(obj):
            """Get default value."""
            class_name = obj.__class__.__name__
            if class_name == 'LazyStorageJSON':
                return ''

            raise TypeError(f'Object of type {class_name} is not JSON serializable')

        with open(inputs_path, 'w') as file:
            json.dump(inputs, file, default=default)

        # Generate volume maps required to expose needed files.
        volume_maps = {
            PYTHON_RUNTIME_DIRNAME: PYTHON_RUNTIME_VOLUME,
            PYTHON_PROGRAM_FILENAME: PYTHON_PROGRAM_VOLUME,
            PYTHON_INPUTS_FILENAME: PYTHON_INPUTS_VOLUME,
        }

        return volume_maps
1259964
def prepare_fds (self):
        """"""
        if '_in' in self.options:
            i= self.options['_in']
            logger.debug ('_in: %r', i)

            # this condition is complex, but basically handles any type of input
            # that is not going to be handled later in client()
            if (     not isinstance (i, io.IOBase)      # file and such objects
                 and type (i) not in (int, str, bytes)  # fd's and file names
                 and i is not None                      # special value for /dev/null
                 and not isinstance (i, Command) ):     # Command's
                if self.options['_in_tty']:
                    # TODO: no support yet for input from file when _in_tty
                    # NOTE: os.openpty() returns (master, slave)
                    # but when writing master=w, slave=r
                    logger.debug ('_in: using tty')
                    (master, slave)= os.openpty ()
                    self.stdin_pipe= (slave, master)
                else:
                    logger.debug ("_in:%s creates a pipe()", type (i))
                    self.stdin_pipe= os.pipe ()
            elif isinstance (i, Command):
                if i.options.get ('_out', None)==Capture:
                    # if it's a captured command, create a pipe to feed the data
                    logger.debug ("_in::Command, _in._out==Capture creates a pipe()")
                    self.stdin_pipe= os.pipe ()
                elif i.options.get ('_out', None)==Pipe:
                    # if it's a piped command, use its pipe and hope it runs in the bg
                    logger.debug ("_in::Command uses the stdout_pipe")
                    self.stdin_pipe= i.stdout_pipe

        logger.debug ("stdin_pipe: %s", self.stdin_pipe)

        if '_out' in self.options:
            if self.options['_out']==Capture:
                if self.options['_out_tty']:
                    if self.options['_in_tty']:
                        # we use a copy of the pty created for the stdin
                        logger.debug ('duping tty form _in to _out')
                        self.stdout_pipe= (os.dup (self.stdin_pipe[1]),
                                           os.dup (self.stdin_pipe[0]))
                    else:
                        # this time the order is right
                        logger.debug ('_out: using tty')
                        (master, slave)= os.openpty ()
                        self.stdout_pipe= (master, slave)
                else:
                    logger.debug ("_out==Capture creates a pipe()")
                    self.stdout_pipe= os.pipe ()
            elif self.options['_out']==Pipe:
                # this pipe should be picked up by the outer Command
                logger.debug ("_out==Pipe creates a pipe()")
                self.stdout_pipe= os.pipe ()

        logger.debug ("stdout_pipe: %s", self.stdout_pipe)

        if '_err' in self.options:
            if self.options['_err']==Capture:
                # if stdout is also Capture'd, then use the same pipe
                if not '_out' in self.options or self.options['_out']!=Capture:
                    # if stdout is a tty, hook to that one
                    if self.options['_out_tty']:
                        logger.debug ('duping tty form _out to _err')
                        self.stderr_pipe= (os.dup (self.stdout_pipe[0]),
                                           os.dup (self.stdout_pipe[1]))
                    else:
                        logger.debug ("_err==Capture creates a pipe()")
                        self.stderr_pipe= os.pipe ()
            elif self.options['_err']==Pipe:
                # this pipe should be picked up by the outer Command
                logger.debug ("_err==Pipe creates a pipe()")
                self.stderr_pipe= os.pipe ()

        logger.debug ("stderr_pipe: %s", self.stderr_pipe)
1258508
def prepare(self):
        '''
        
        '''
        super(ProxyMinion, self).prepare()

        if not self.values.proxyid:
            self.error('salt-proxy requires --proxyid')

        # Proxies get their ID from the command line.  This may need to change in
        # the future.
        # We used to set this here.  Now it is set in ProxyMinionOptionParser
        # by passing it via setup_config to config.minion_config
        # self.config['id'] = self.values.proxyid

        try:
            if self.config['verify_env']:
                confd = self.config.get('default_include')
                if confd:
                    # If 'default_include' is specified in config, then use it
                    if '*' in confd:
                        # Value is of the form "minion.d/*.conf"
                        confd = os.path.dirname(confd)
                    if not os.path.isabs(confd):
                        # If configured 'default_include' is not an absolute
                        # path, consider it relative to folder of 'conf_file'
                        # (/etc/salt by default)
                        confd = os.path.join(
                            os.path.dirname(self.config['conf_file']), confd
                        )
                else:
                    confd = os.path.join(
                        os.path.dirname(self.config['conf_file']), 'proxy.d'
                    )

                v_dirs = [
                    self.config['pki_dir'],
                    self.config['cachedir'],
                    self.config['sock_dir'],
                    self.config['extension_modules'],
                    confd,
                ]

                verify_env(
                    v_dirs,
                    self.config['user'],
                    permissive=self.config['permissive_pki_access'],
                    root_dir=self.config['root_dir'],
                    pki_dir=self.config['pki_dir'],
                )
        except OSError as error:
            self.environment_failure(error)

        self.setup_logfile_logger()
        verify_log(self.config)
        self.action_log_info('Setting up "{0}"'.format(self.config['id']))

        migrations.migrate_paths(self.config)

        # Bail out if we find a process running and it matches out pidfile
        if self.check_running():
            self.action_log_info('An instance is already running. Exiting')
            self.shutdown(1)

        # TODO: AIO core is separate from transport
        # Late import so logging works correctly
        import salt.minion
        # If the minion key has not been accepted, then Salt enters a loop
        # waiting for it, if we daemonize later then the minion could halt
        # the boot process waiting for a key to be accepted on the master.
        # This is the latest safe place to daemonize
        self.daemonize_if_required()
        self.set_pidfile()
        if self.config.get('master_type') == 'func':
            salt.minion.eval_master_func(self.config)
        self.minion = salt.minion.ProxyMinionManager(self.config)
617894
def _prepare_connection(**nxos_api_kwargs):
    '''
    
    '''
    nxos_api_kwargs = clean_kwargs(**nxos_api_kwargs)
    init_kwargs = {}
    # Clean up any arguments that are not required
    for karg, warg in six.iteritems(nxos_api_kwargs):
        if karg in RPC_INIT_KWARGS:
            init_kwargs[karg] = warg
    if 'host' not in init_kwargs:
        init_kwargs['host'] = 'localhost'
    if 'transport' not in init_kwargs:
        init_kwargs['transport'] = 'https'
    if 'port' not in init_kwargs:
        init_kwargs['port'] = 80 if init_kwargs['transport'] == 'http' else 443
    verify = init_kwargs.get('verify', True)
    if isinstance(verify, bool):
        init_kwargs['verify_ssl'] = verify
    else:
        init_kwargs['ca_bundle'] = verify
    if 'rpc_version' not in init_kwargs:
        init_kwargs['rpc_version'] = '2.0'
    if 'timeout' not in init_kwargs:
        init_kwargs['timeout'] = 60
    return init_kwargs