code: def expect_prompt(self, consume=True):
          
          if consume:
              result = self.expect(self.get_prompt())
          else:
              self._dbg(1, "DO NOT CONSUME PROMPT!")
              result = self.waitfor(self.get_prompt())
  
          # We skip the first line because it contains the echo of the command
          # sent.
          self._dbg(5, "Checking %s for errors" % repr(self.response))
          for line in self.response.split('\n')[1:]:
              for prompt in self.get_error_prompt():
                  if not prompt.search(line):
                      continue
                  args = repr(prompt.pattern), repr(line)
                  self._dbg(5, "error prompt (%s) matches %s" % args)
                  raise InvalidCommandException('Device said:\n' + self.response)
  
          return result
docs: Monitors the data received from the remote host and waits for a
          prompt in the response. The prompt attempts to use
          a sane default that works with many devices running Unix, IOS,
          IOS-XR, or Junos and others. If that fails, a custom prompt may
          also be defined using the set_prompt() method.
          This method also stores the received data in the response
          attribute (self.response).
  
          :type  consume: boolean (Default: True)
          :param consume: Whether to consume the prompt from the buffer or not.
          :rtype:  int, re.MatchObject
          :return: The index of the prompt regular expression that matched,
            and the match object.