parameters: (self, success_re, error_re, clear=False)
docstring: Blocks until a matching line is logged or a timeout occurs.
  
      Args:
        success_re: A compiled re to search each line for.
        error_re: A compiled re which, if found, terminates the search for
            |success_re|. If None is given, no error condition will be detected.
        clear: If True the existing logcat output will be cleared, defaults to
            false.
  
      Raises:
        pexpect.TIMEOUT upon the timeout specified by StartMonitoringLogcat().
  
      Returns:
        The re match object if |success_re| is matched first or None if |error_re|
        is matched first.
docstring_summary: Blocks until a matching line is logged or a timeout occurs.
docstring_tokens: Blocks until a matching line is logged or a timeout occurs .
function: def WaitForLogMatch(self, success_re, error_re, clear=False):
      """Blocks until a matching line is logged or a timeout occurs.
  
      Args:
        success_re: A compiled re to search each line for.
        error_re: A compiled re which, if found, terminates the search for
            |success_re|. If None is given, no error condition will be detected.
        clear: If True the existing logcat output will be cleared, defaults to
            false.
  
      Raises:
        pexpect.TIMEOUT upon the timeout specified by StartMonitoringLogcat().
  
      Returns:
        The re match object if |success_re| is matched first or None if |error_re|
        is matched first.
      """
      logging.info('<<< Waiting for logcat:' + str(success_re.pattern))
      t0 = time.time()
      while True:
        if not self._logcat:
          self.StartMonitoringLogcat(clear)
        try:
          while True:
            # Note this will block for upto the timeout _per log line_, so we need
            # to calculate the overall timeout remaining since t0.
            time_remaining = t0 + self._logcat.timeout - time.time()
            if time_remaining < 0: raise pexpect.TIMEOUT(self._logcat)
            self._logcat.expect(PEXPECT_LINE_RE, timeout=time_remaining)
            line = self._logcat.match.group(1)
            if error_re:
              error_match = error_re.search(line)
              if error_match:
                return None
            success_match = success_re.search(line)
            if success_match:
              return success_match
            logging.info('<<< Skipped Logcat Line:' + str(line))
        except pexpect.TIMEOUT:
          raise pexpect.TIMEOUT(
              'Timeout (%ds) exceeded waiting for pattern "%s" (tip: use -vv '
              'to debug)' %
              (self._logcat.timeout, success_re.pattern))
        except pexpect.EOF:
          # It seems that sometimes logcat can end unexpectedly. This seems
          # to happen during Chrome startup after a reboot followed by a cache
          # clean. I don't understand why this happens, but this code deals with
          # getting EOF in logcat.
          logging.critical('Found EOF in adb logcat. Restarting...')
          # Rerun spawn with original arguments. Note that self._logcat.args[0] is
          # the path of adb, so we don't want it in the arguments.
          self._logcat = pexpect.spawn('adb',
                                       self._logcat.args[1:],
                                       timeout=self._logcat.timeout,
                                       logfile=self._logcat.logfile)
function_tokens: def WaitForLogMatch ( self , success_re , error_re , clear = False ) : logging . info ( '<<< Waiting for logcat:' + str ( success_re . pattern ) ) t0 = time . time ( ) while True : if not self . _logcat : self . StartMonitoringLogcat ( clear ) try : while True : # Note this will block for upto the timeout _per log line_, so we need # to calculate the overall timeout remaining since t0. time_remaining = t0 + self . _logcat . timeout - time . time ( ) if time_remaining < 0 : raise pexpect . TIMEOUT ( self . _logcat ) self . _logcat . expect ( PEXPECT_LINE_RE , timeout = time_remaining ) line = self . _logcat . match . group ( 1 ) if error_re : error_match = error_re . search ( line ) if error_match : return None success_match = success_re . search ( line ) if success_match : return success_match logging . info ( '<<< Skipped Logcat Line:' + str ( line ) ) except pexpect . TIMEOUT : raise pexpect . TIMEOUT ( 'Timeout (%ds) exceeded waiting for pattern "%s" (tip: use -vv ' 'to debug)' % ( self . _logcat . timeout , success_re . pattern ) ) except pexpect . EOF : # It seems that sometimes logcat can end unexpectedly. This seems # to happen during Chrome startup after a reboot followed by a cache # clean. I don't understand why this happens, but this code deals with # getting EOF in logcat. logging . critical ( 'Found EOF in adb logcat. Restarting...' ) # Rerun spawn with original arguments. Note that self._logcat.args[0] is # the path of adb, so we don't want it in the arguments. self . _logcat = pexpect . spawn ( 'adb' , self . _logcat . args [ 1 : ] , timeout = self . _logcat . timeout , logfile = self . _logcat . logfile )