parameters: (args, timeout, cwd=None, shell=False,
                                       logfile=None)
return_statement: return process.returncode, str_output
docstring: Executes a subprocess with a timeout.
  
    Args:
      args: List of arguments to the program, the program to execute is the first
        element.
      timeout: the timeout in seconds or None to wait forever.
      cwd: If not None, the subprocess's current directory will be changed to
        |cwd| before it's executed.
      shell: Whether to execute args as a shell command. Must be True if args
        is a string and False if args is a sequence.
      logfile: Optional file-like object that will receive output from the
        command as it is running.
  
    Returns:
      The 2-tuple (exit code, output).
docstring_summary: Executes a subprocess with a timeout.
docstring_tokens: Executes a subprocess with a timeout .
function: def GetCmdStatusAndOutputWithTimeout(args, timeout, cwd=None, shell=False,
                                       logfile=None):
    """Executes a subprocess with a timeout.
  
    Args:
      args: List of arguments to the program, the program to execute is the first
        element.
      timeout: the timeout in seconds or None to wait forever.
      cwd: If not None, the subprocess's current directory will be changed to
        |cwd| before it's executed.
      shell: Whether to execute args as a shell command. Must be True if args
        is a string and False if args is a sequence.
      logfile: Optional file-like object that will receive output from the
        command as it is running.
  
    Returns:
      The 2-tuple (exit code, output).
    """
    _ValidateAndLogCommand(args, cwd, shell)
    output = StringIO.StringIO()
    process = Popen(args, cwd=cwd, shell=shell, stdout=subprocess.PIPE,
                    stderr=subprocess.STDOUT)
    try:
      for data in _IterProcessStdout(process, timeout=timeout):
        if logfile:
          logfile.write(data)
        output.write(data)
    except TimeoutError:
      raise TimeoutError(output.getvalue())
  
    str_output = output.getvalue()
    logging.debug('STDOUT+STDERR: %s%s', str_output[:4096].rstrip(),
                  '<truncated>' if len(str_output) > 4096 else '')
    return process.returncode, str_output
function_tokens: def GetCmdStatusAndOutputWithTimeout ( args , timeout , cwd = None , shell = False , logfile = None ) : _ValidateAndLogCommand ( args , cwd , shell ) output = StringIO . StringIO ( ) process = Popen ( args , cwd = cwd , shell = shell , stdout = subprocess . PIPE , stderr = subprocess . STDOUT ) try : for data in _IterProcessStdout ( process , timeout = timeout ) : if logfile : logfile . write ( data ) output . write ( data ) except TimeoutError : raise TimeoutError ( output . getvalue ( ) ) str_output = output . getvalue ( ) logging . debug ( 'STDOUT+STDERR: %s%s' , str_output [ : 4096 ] . rstrip ( ) , '<truncated>' if len ( str_output ) > 4096 else '' ) return process . returncode , str_output