Tail a specified stream (stdout or stderr) by num_lines.
182197
def tail(self, stream='stdout', num_lines=10):
        
        target = self._map_string_to_file(stream)
        if not target:  # no current temp file
            last_run = self.backend.get_latest_run_log(self.parent_job.job_id,
                                                       self.name)
            if not last_run:
                return None
            return self._tail_string(last_run['tasks'][self.name][stream],
                                     num_lines)
        else:
            return self._tail_temp_file(target, num_lines)
918806
private void createProcessErrorPump(InputStream is, OutputStream os) {
        errorThread = createPump(is, os, CLOSE_STDOUT_AND_STDERR_INSTREAMS_WHEN_EXHAUSTED);
    }
645505
def tail(self) -> 'List':
        """"""

        lambda_list = self._get_value()
        return List(lambda_list(lambda _, tail: tail))
188574
def read_line_stderr(self, time_limit=None):
        
        if self.proc is not None:
            return self.proc.stderr.readline().decode()
        else:
            return None
837320
private void startPipeErrorStreamThread() {
        Thread daemon = new Thread(() -> {
            while (true) {
                try {
                    String line = stderr.readLine();
                    System.err.println(line);
                    if (line == null) {
                        break;
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });

        daemon.setDaemon(true);
        daemon.start();
    }
74377
def log_to_stream(stream=sys.stderr, level=logging.NOTSET,
                  fmt=logging.BASIC_FORMAT):
    
    fmt = Formatter(fmt)
    handler = StreamHandler()
    handler.setFormatter(fmt)
    handler.setLevel(level)

    log.addHandler(handler)
1370764
def iterstd(cmd, std="out", **kwargs):
    """"""
    def _readline():
        while True:
            line = getattr(proc, "std"+std).readline()
            if line != b"":
                yield line.rstrip().decode("UTF-8", "replace")
            else:
                break
    kwargs['shell'] = True
    kwargs['stdout'] = subprocess.PIPE
    kwargs['stderr'] = subprocess.PIPE
    if sys.version_info >= (3,0):
        with subprocess.Popen(cmd, **kwargs) as proc:
            for line in _readline(): yield line
    else:
        proc = subprocess.Popen(cmd, **kwargs)
        for line in _readline(): yield line
        proc.kill()
1078738
def tail(path, lines):
    '''
    
    '''
    path = os.path.expanduser(path)
    lines_found = []
    buffer_size = 4098

    if not os.path.isfile(path):
        raise SaltInvocationError('File not found: {0}'.format(path))

    if not __utils__['files.is_text'](path):
        raise SaltInvocationError(
            'Cannot tail a binary file: {0}'.format(path))

    try:
        lines = int(lines)
    except ValueError:
        raise SaltInvocationError('file.tail: \'lines\' value must be an integer')

    try:
        with salt.utils.fopen(path) as tail_fh:
            blk_cnt = 1
            size = os.stat(path).st_size

            if size > buffer_size:
                tail_fh.seek(-buffer_size * blk_cnt, os.SEEK_END)
            data = string.split(tail_fh.read(buffer_size), os.linesep)

            for i in range(lines):
                while len(data) == 1 and ((blk_cnt * buffer_size) < size):
                    blk_cnt += 1
                    line = data[0]
                    try:
                        tail_fh.seek(-buffer_size * blk_cnt, os.SEEK_END)
                        data = string.split(tail_fh.read(buffer_size) + line, os.linesep)
                    except IOError:
                        tail_fh.seek(0)
                        data = string.split(tail_fh.read(size - (buffer_size * (blk_cnt - 1))) + line, os.linesep)

                line = data[-1]
                data.pop()
                lines_found.append(line)

        return lines_found[-lines:]
    except (OSError, IOError):
        raise CommandExecutionError('Could not tail \'{0}\''.format(path))
570518
async def iter_lines(
            self,
            *cmds: str,
            stream: str='both') -> AsyncGenerator[str, None]:
        """"""
        sps = self.spawn(*cmds)
        if stream == 'both':
            agen = amerge(
                amerge(*[sp.stdout for sp in sps]),
                amerge(*[sp.stderr for sp in sps]))
        elif stream == 'stdout':
            agen = amerge(*[sp.stdout for sp in sps])
        elif stream == 'stderr':
            agen = amerge(*[sp.stderr for sp in sps])
        else:
            raise SublemonRuntimeError(
                'Invalid `stream` kwarg received: `' + str(stream) + '`')
        async for line in agen:
            yield line.decode('utf-8').rstrip()
675729
public static void tail(File file, Charset charset, LineHandler handler) {
		new Tailer(file, charset, handler).start();
	}
1268917
def _skip_lines(self, n):
        ''''''
        for i in range(n):
            self.line = next(self.output)
        return self.line
1176346
def stream_lines(tokens, line_num)
      yield line_start(line_num)

      tokens.each do |token, value|
        yield @inner.span(token, value)
      end

      yield line_end(line_num)
    end
443878
def log(lines, log_file=None):
        """"""
        err = False
        for line in lines:
            print(line)
            if log_file is not None:
                UtilClass.writelog(log_file, line, 'append')
            if 'BAD TERMINATION' in line.upper():
                err = True
                break
        if err:
            TauDEM.error('Error occurred when calling TauDEM function, please check!', log_file)
1309920
def _mudraw(buffer, fmt):
    """"""
    with NamedTemporaryFile(suffix='.pdf') as tmp_in:
        tmp_in.write(buffer)
        tmp_in.seek(0)
        tmp_in.flush()

        proc = run(
            ['mudraw', '-F', fmt, '-o', '-', tmp_in.name], stdout=PIPE, stderr=PIPE
        )
        if proc.stderr:
            raise RuntimeError(proc.stderr.decode())
        return proc.stdout
148752
def err(*args):
    
    for value in args:
        sys.stderr.write(value)

    sys.stderr.write(os.linesep)
577333
def tail(self, bytes):
        
        self.io.seek(max(0, self.size() - bytes))
        return self.io.read()
354918
def handle_streams(stdout_stream, stderr_stream, &block)
        logger.debug "Monitoring stdout/stderr streams for output"
        streams = [stdout_stream, stderr_stream]
        until streams.empty?
          # Find which streams are ready for reading, timeout 0.1s
          selected, = select(streams, nil, nil, 0.1)

          # Try again if none were ready
          next if selected.nil? or selected.empty?

          selected.each do |stream|
            if stream.eof?
              logger.debug "Stream reached end-of-file"
              if @success.nil?
                logger.debug "Process hasn't finished, keeping stream"
              else
                logger.debug "Removing stream"
                streams.delete(stream)
              end
              next
            end

            while data = @reader.call(stream)
              data = ((@options[:mode] == :chars) ? data.chr : data)
              stream_name = (stream == stdout_stream) ? :stdout : :stderr
              output data, stream_name, &block unless block.nil?
              buffer data, stream_name unless @options[:no_buffer]
            end
          end
        end
      end