Allow for custom stdout/stderr/stdin streams when instantiating a Command.
Allow for custom stdout/stderr/stdin streams when instantiating a Command.

`Command` now takes `stdout`, `stderr`, and `stdin` arguments. These are
expected, in the case of custom streams, to be `io.TextIOWrapper`
instances, wrapping a `io.BytesIO`.

The standard and JSON output wrappers on `Command` instances will wrap
these instead of assuming the versions on `sys`. The log stream will
wrap `stderr` as well (it normally defaults to `sys.stderr`), ensuring
that all logs are, by default, outputted to that stream. This can, as
always, be overridden with a more explicit logging setup if automating
RBTools.

There's also `*_is_atty` attributes computed for each of these streams
when instantiating. These replace the previous `.isatty()` checks, and
are more robust, handling the case where this attribute is missing.

This will be used for unit tests that need to capture command output or
simulate input.

Testing Done:
Tested running RBTools commands on Python 2, 3.6, and 3.10. Checked
default stdout, stderr, and stdin functionality.

Made use of this in upcoming unit test support. Verified that I could
override the streams successfully on all supported versions of Python
and grab the resulting output (or supply the resulting input).

Reviewed at https://reviews.reviewboard.org/r/12242/

reviewboard/rbtools,reviewboard/rbtools,reviewboard/rbtools