def run(*popenargs, **kwargs):
stdin = kwargs.pop('<STR_LIT:input>', None)<EOL>timeout = kwargs.pop('<STR_LIT>', None)<EOL>check = kwargs.pop('<STR_LIT>', False)<EOL>if stdin is not None:<EOL><INDENT>if '<STR_LIT>' in kwargs:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>kwargs['<STR_LIT>'] = PIPE<EOL><DEDENT>process = Popen(*popenargs, **kwargs)<EOL>try:<EOL><INDENT>if __timeout__:<EOL><INDENT>stdout, stderr = process.communicate(stdin, timeout=timeout)<EOL><DEDENT>else:<EOL><INDENT>stdout, stderr = process.communicate(stdin)<EOL><DEDENT><DEDENT>except TimeoutExpired:<EOL><INDENT>process.kill()<EOL>stdout, stderr = process.communicate()<EOL>raise _TimeoutExpired(process.args, timeout, output=stdout,<EOL>stderr=stderr)<EOL><DEDENT>except:<EOL><INDENT>process.kill()<EOL>process.wait()<EOL>raise<EOL><DEDENT>retcode = process.poll()<EOL>if check and retcode:<EOL><INDENT>raise CalledProcessError(retcode, popenargs,<EOL>output=stdout, stderr=stderr)<EOL><DEDENT>return CompletedProcess(popenargs, retcode, stdout, stderr)<EOL>
Run command with arguments and return a `CompletedProcess` instance.

    The returned instance will have attributes args, returncode, stdout and
    stderr.

    By default, stdout and stderr are not captured, and those attributes
    will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them.

    If `check` is True and the exit code was non-zero, it raises a
    CalledProcessError. The CalledProcessError object will have the return code
    in the returncode attribute, and output & stderr attributes if those
    streams were captured.

    If `timeout` is given, and the process takes too long, a TimeoutExpired
    exception will be raised, if timeout is supported in the underlying Popen
    implementation (e.g. Python >= 3.2, or an available subprocess32 package).

    There is an optional argument `input`, allowing you to
    pass a string to the subprocess's stdin.  If you use this argument
    you may not also use the Popen constructor's `stdin` argument, as
    it will be used internally.

    The other arguments are the same as for the Popen constructor.

    If universal_newlines=True is passed, the `input` argument must be a
    string and stdout/stderr in the returned object will be strings rather than
    bytes.