docs: def run(cmd, stdout=None, stderr=None, **kwargs):
      """
      A blocking wrapper around subprocess.Popen(), but with a simpler interface
      for the stdout/stderr arguments:
  
      stdout=False / stderr=False
          stdout/stderr will be redirected to /dev/null (or discarded in some
          other suitable manner)
      stdout=True / stderr=True
          stdout/stderr will be captured and returned as a list of lines.
      stdout=None
          stdout will be redirected to the python process's stdout, which may be
          a tty (same as using stdout=subprocess.None)
      stderr=None:
          stderr will be redirected to the python process's stderr, which may be
          a tty (same as using stderr=subprocess.None)
      stderr="STDOUT"
          Same as using stderr=subprocess.STDOUT
  
      The return value will be a tuple of (exitcode, stdout, stderr)
  
      If stdout and/or stderr were not captured, they will be None instead.
      """
      devnull = None
      try:
          stdoutfilter = None
          stderrfilter = None
  
          wantstdout = False
          wantstderr = False
          if stdout is False:
              devnull = open('/dev/null', 'w')
              stdout = devnull
          elif stdout is True:
              stdout = subprocess.PIPE
              wantstdout = True
          elif callable(stdout):
              stdoutfilter = partial(stdout)
              stdout = subprocess.PIPE
          else:
              assert stdout is None, "Invalid stdout %r" % stdout
  
          if stderr is False:
              if devnull is None:
                  devnull = open('/dev/null', 'w')
              stderr = devnull
          elif stderr is True:
              stderr = subprocess.PIPE
              wantstderr = True
          elif stderr == "STDOUT":
              stderr = subprocess.STDOUT
          elif callable(stderr):
              stderrfilter = partial(stderr)
              stderr = subprocess.PIPE
          else:
              assert stderr is None, "Invalid stderr %r" % stderr
  
          if (stdoutfilter or stderrfilter) and asyncio:
              # run background process asynchronously and filter output as
              # it is running
              exitcode, out, err, = _runasync(stdoutfilter,
                                              stderrfilter,
                                              cmd,
                                              stdout=stdout,
                                              stderr=stderr,
                                              **kwargs)
              if not wantstdout:
                  out = None
              if not wantstderr:
                  err = None
              return exitcode, out, err
  
          proc = subprocess.Popen(cmd, stdout=stdout, stderr=stderr, **kwargs)
          out, err = proc.communicate()
          if not wantstdout:
              if stdoutfilter:
                  stdoutfilter(out, True)
              out = None
          if not wantstderr:
              if stderrfilter:
                  stderrfilter(err, True)
              err = None
          return proc.returncode, out, err
      finally:
          if devnull is not None:
              devnull.close()