Expect a command.

        :param reader: The reader to use.
        :returns: The command data.
558516
async def _expect_command(cls, reader, name):
        
        size_type = struct.unpack('B', await reader.readexactly(1))[0]

        if size_type == 0x04:
            size = struct.unpack('!B', await reader.readexactly(1))[0]
        elif size_type == 0x06:
            size = struct.unpack('!Q', await reader.readexactly(8))[0]
        else:
            raise ProtocolError(
                "Unexpected size type: %0x" % size_type,
                fatal=True,
            )

        name_size = struct.unpack('B', await reader.readexactly(1))[0]

        if name_size != len(name):
            raise ProtocolError(
                "Unexpected command name size: %s (expecting %s)" % (
                    name_size,
                    len(name),
                ),
                fatal=True,
            )

        c_name = await reader.readexactly(name_size)

        if c_name != name:
            raise ProtocolError(
                "Unexpected command name: %s (expecting %s)" % (c_name, name),
                fatal=True,
            )

        return await reader.readexactly(size - name_size - 1)
161399
def get_command(self):
        
        cmd = None
        count = len(self.command_list)
        if count > 0:
            cmd = self.command_list.pop(0)
        ## If that was the last line, turn off lines_pending
        if count == 1:
            self.cmd_ready = False
        return cmd
460610
def _ready_for_reading(self, timeout=None):
        
        handles = [self._event, self._console_input_reader.handle]
        handles.extend(self._read_fds.keys())
        return _wait_for_handles(handles, timeout)
625895
def _PromptUserForInput(self, input_text):
    
    self._output_writer.Write('{0:s}: '.format(input_text))
    return self._input_reader.Read()
292831
def command(command)
    
      if ! @authed
        raise NetworkException.new("You must authenticate the connection successfully before sending commands.")
      end

      @packet = Packet::Source.new
      @packet.command(command)

      @socket.print @packet.to_s
      rpacket = build_response_packet

      if rpacket.command_type != Packet::Source::RESPONSE_NORM
        raise NetworkException.new("error sending command: #{rpacket.command_type}")
      end

      if @return_packets
        return rpacket
      else
        return rpacket.string1
      end
    end
530614
def read_input(prompt, save_hist = true)
      line = prepare_input(prompt)
      return unless line

      history.push(line) if save_hist

      command_queue.concat(split_commands(line))
      command_queue.shift
    end
1257092
def _expect_method(self, command):
        
        child = pexpect.spawn(self._ipmitool_path, self.args + command)
        
        i = child.expect([pexpect.TIMEOUT, 'Password: '], timeout=10)
        if i == 0:
            child.terminate()
            self.error = 'ipmitool command timed out'
            self.status = 1
        else:
            child.sendline(self.password)
        
        i = child.expect([pexpect.TIMEOUT, pexpect.EOF], timeout=10)
        if i == 0:
            child.terminate()
            self.error = 'ipmitool command timed out'
            self.status = 1
        else:
            if child.exitstatus:
                self.error = child.before
            else:
                self.output = child.before

            self.status = child.exitstatus
            child.close()
830560
def get_command(self, mode, txt=''):
        
        if mode == 'COMMAND':
            self.prompt = '> '
        elif mode == 'ADD':
            self.prompt = 'ADD > '
        elif mode == 'QUERY':
            self.prompt = '?? > '
        if txt == '':
            txt = input(self.prompt)
        return txt
1259592
private static BufferedReader bufferInput( Reader reader )
    {
        BufferedReader in;
        if( reader instanceof BufferedReader )
        {
            in = (BufferedReader) reader;
        }
        else
        {
            in = new BufferedReader( reader );
        }
        return in;
    }
726256
def load_reader(reader_configs, **reader_kwargs):
    """"""
    reader_info = read_reader_config(reader_configs)
    reader_instance = reader_info['reader'](config_files=reader_configs, **reader_kwargs)
    return reader_instance
1097879
def decode_data_with_length(reader) -> bytes:
    
    length_bytes = yield from read_or_raise(reader, 2)
    bytes_length = unpack("!H", length_bytes)
    data = yield from read_or_raise(reader, bytes_length[0])
    return data
942835
def get_reader_factory_for(self, name, *, format=None):
        
        return self.get_factory_for(READER, name, format=format)
846489
def _get_reader(self, network_reader):
        
        with (yield from self._lock):
            if self._reader_process is None:
                self._reader_process = network_reader
            if self._reader:
                if self._reader_process == network_reader:
                    self._current_read = asyncio.async(self._reader.read(READ_SIZE))
                    return self._current_read
        return None
660163
def acquire_reader(self):
        
        with self.mutex:
            while self.rwlock < 0 or self.rwlock == self.max_reader_concurrency or self.writers_waiting:
                self.readers_ok.wait()
            self.rwlock += 1
930399
def execute(self, command):
        '''
        
        '''
        process = Popen(command, stdout=PIPE, stderr=STDOUT, universal_newlines=True)
        while True:
            if process.poll() is not None:
                self.returncode = process.returncode  # pylint: disable=W0201
                break
            yield process.stdout.readline()
1171731
def execute(self, input_data):
        
        input_data = input_data['info']
        type_tag = input_data['type_tag']
        if type_tag == 'help':
            return {'help': input_data['help'], 'type_tag': input_data['type_tag']}
        elif type_tag == 'worker':
            out_keys = ['name', 'dependencies', 'docstring', 'type_tag'] 
            return {key: value for key, value in input_data.iteritems() if key in out_keys}
        elif type_tag == 'command':
            out_keys = ['command', 'sig', 'docstring', 'type_tag']
            return {key: value for key, value in input_data.iteritems() if key in out_keys}
        elif type_tag == 'other':
            return input_data
        else:
            print 'Got a malformed info object %s' % input_data
            return input_data
913575
def validate(cls, job_config):
    
    if job_config.input_reader_cls != cls:
      raise errors.BadReaderParamsError(
          "Expect input reader class %r, got %r." %
          (cls, job_config.input_reader_cls))