Return StdIn in PUT, PATCH or DELETE
552836
private function getStdIn(string $method, array $query, array &$server) : array
    {
        if ($method === 'put' || $method === 'patch' || $method === 'delete') {
            $server[HttpMethodParams::CONTENT_TYPE] = HttpMethodParams::FORM_URL_ENCODE;
            file_put_contents($this->stdIn, http_build_query($query));

            return $server;
        }

        return $server;
    }
404096
def do_rm(self, line):
        ""
        table, line = self.get_table_params(line)
        expected, line = self.get_expected(line)

        args = self.getargs(line)

        if "-v" in args:
            ret = "ALL_OLD"
            args.remove("-v")
        else:
            ret = None

        hkey = self.get_typed_key_value(table, args[0], True)
        rkey = self.get_typed_key_value(table, args[1], False) if len(args) > 1 else None

        item = table.new_item(hash_key=hkey, range_key=rkey)
        item = item.delete(expected_value=expected, return_values=ret)
        self.pprint(item)

        if self.consumed:
            print "consumed units:", item.consumed_units
880358
def _save_stdin(self, stdin):
		
		self.temp_dir = TemporaryDirectory()
		file_path = os.path.join(self.temp_dir.name, 'dataset')

		try:
			with open(file_path, 'w') as f:
				for line in stdin:
					f.write(line)
		except TypeError:
			self.temp_dir.cleanup()
			raise ValueError('Could not read stdin')

		return file_path
345409
def send_inputs_patch(sequence)
      if has_default_thread?
        begin
          cmd = { :name => :set_inputs_patch, :patch => sequence.inputs_patch }
          @client.send_command(cmd)
        rescue Exception => e
          fail('Failed to update inputs', Log.format("Failed to apply inputs patch after execution", e, :trace))
        end
      end
      true
    ensure
      stop
    end
796799
def puts_err(s='', newline=True, stream=STDERR):
    """"""
    puts(s, newline, stream)
459269
def stdin_read(self, data):
        

        data = data.strip().decode("utf-8")
        self.log("Incoming:", data, lvl=verbose)

        if len(data) == 0:
            self.log('Use /help to get a list of enabled cli hooks')
            return

        if data[0] == "/":
            cmd = data[1:]
            args = []
            if ' ' in cmd:
                cmd, args = cmd.split(' ', maxsplit=1)
                args = args.split(' ')
            if cmd in self.hooks:
                self.log('Firing hooked event:', cmd, args, lvl=debug)
                self.fireEvent(self.hooks[cmd](*args))
            # TODO: Move these out, so we get a simple logic here
            elif cmd == 'frontend':
                self.log("Sending %s frontend rebuild event" %
                         ("(forced)" if 'force' in args else ''))
                self.fireEvent(
                    frontendbuildrequest(force='force' in args,
                                         install='install' in args),
                    "setup")
            elif cmd == 'backend':
                self.log("Sending backend reload event")
                self.fireEvent(componentupdaterequest(force=False), "setup")
            else:
                self.log('Unknown Command:', cmd, '. Use /help to get a list of enabled '
                                                  'cli hooks')
272703
def standard_input():
    """"""
    with click.get_text_stream("stdin") as stdin:
        while stdin.readable():
            line = stdin.readline()
            if line:
                yield line.strip().encode("utf-8")
1100762
def execute!
      exit_code = begin
        # Thor accesses these streams directly rather than letting them be injected, so we replace them...
        $stderr = @stderr
        $stdin = @stdin
        $stdout = @stdout

        # Run our normal Thor app the way we know and love.
        DCMetro::Cli::Application.start(ARGV)

        # Thor::Base#start does not have a return value, assume success if no exception is raised.
        0
      rescue StandardError => e
        # The ruby interpreter would pipe this to STDERR and exit 1 in the case of an unhandled exception
        b = e.backtrace
        @stderr.puts("#{b.shift}: #{e.message} (#{e.class})")
        @stderr.puts(b.map{|s| "\tfrom #{s}"}.join("\n"))
        1
      rescue SystemExit => e
        e.status
      ensure
        # TODO: reset your app here, free up resources, etc.
        # Examples:
        # MyApp.logger.flush
        # MyApp.logger.close
        # MyApp.logger = nil
        #
        # MyApp.reset_singleton_instance_variables

        # ...then we put the streams back.
        $stderr = STDERR
        $stdin = STDIN
        $stdout = STDOUT
      end

      # Proxy our exit code back to the injected kernel.
      @kernel.exit(exit_code)
    end
160741
def command(cmd,match = //)
      @stdin.puts(cmd)
      response = ""
      until response =~ match
        response = @stdout.gets
      end
      response.gsub("\e[A\r\e[K","")
    end
1212292
def nailgunned_stdio(cls, sock, env, handle_stdin=True):
    """"""
    # Determine output tty capabilities from the environment.
    stdin_isatty, stdout_isatty, stderr_isatty = NailgunProtocol.isatty_from_env(env)
    is_tty_capable = all((stdin_isatty, stdout_isatty, stderr_isatty))

    if is_tty_capable:
      with cls._tty_stdio(env) as finalizer:
        yield finalizer
    else:
      with cls._pipe_stdio(
        sock,
        stdin_isatty,
        stdout_isatty,
        stderr_isatty,
        handle_stdin
      ) as finalizer:
        yield finalizer
966232
def _put_output(self, output: Optional[str]) -> None:
        """"""
        if output is None:
            self._argv.extend(["-f", "null", "-"])
            return

        output_cmd = shlex.split(str(output))
        if len(output_cmd) > 1:
            self._argv.extend(output_cmd)
        else:
            self._argv.append(output)
543557
def csvpatch_cmd(input_csv, input=None, output=None, strict=True):
    
    patch_stream = (sys.stdin
                    if input is None
                    else open(input))
    tocsv_stream = (sys.stdout
                    if output is None
                    else open(output, 'w'))
    fromcsv_stream = open(input_csv)

    try:
        patch_file(patch_stream, fromcsv_stream, tocsv_stream, strict=strict)

    except patch.InvalidPatchError as e:
        error.abort('reading patch, {0}'.format(e.args[0]))

    finally:
        patch_stream.close()
        fromcsv_stream.close()
        tocsv_stream.close()
502976
def stderr(self):
        
        streams = self._payload.get('streams', None)
        return streams[1] if streams is not None and len(streams) >= 2 else ''
769515
def send_stdin(io = nil)
      unless io.nil?
        begin
          send_chunk :stdin, io.read(2048)
        end until io.eof?
        io.close
      end
      send_chunk :stdin_eof
    end
1270016
def _capture_stderr(callable: Callable[..., CaptureResult], *args, **kwargs) -> CaptureResult:
        
        stream = StringIO()
        with redirect_stderr(stream):
            return_value = callable(*args, **kwargs)
        assert return_value.stderr is None, "stderr appears to have already been captured"
        return CaptureResult(return_value=return_value.return_value, stdout=return_value.stdout,
                             stderr=stream.getvalue(), exception=return_value.exception)
974586
def returner(ret):
    '''
    
    '''
    conn = _get_conn(ret)
    cur = conn.cursor()
    sql = '''INSERT INTO salt_returns
            (fun, jid, retval, id, success, full_ret)
            VALUES (?, ?, ?, ?, ?, ?)'''
    cur.execute(
        sql, (
            ret['fun'],
            ret['jid'],
            salt.utils.json.dumps(ret['return']),
            ret['id'],
            ret['success'],
            salt.utils.json.dumps(ret)
        )
    )
    _close_conn(conn)
1327684
def formatreturn(arg, input_is_array=False):
    """"""
    if not input_is_array and arg.size == 1:
        arg = arg.item()
    return arg