9430063 Allow _run_command to capture and return output to stdout or stderr

Authored and Committed by cqi 5 years ago
    Allow _run_command to capture and return output to stdout or stderr
    
    Once process executes successfully, _run_command will return a tuple
    consisting of three elements of process exit code and output to stdout
    and stderr, which could be None if it does not intent to capture and
    return them.
    
    Original behavior is still available. As long as error is
    raised from subprocess or process exits non-zero and stderr output is
    not captured, rpkgError will be raised.
    
    Several examples:
    
    1. run rpmbuild to build SRPM and output to stdout and stderr are not
    captured.
    
      _run_command(['rpmbuild', '-bs', 'pkg.spec'])
    
    2. run rpm to get package metadata from SPEC.
    
      _run_command(
        ['rpm', '-q', '--qf', '%{name}', '--specfile', 'pkg.spec'],
        return_stdout=True, return_text=True)
    
    3. run rpm but error is raised.
    
      _run_command(['rpm', '-q', '-qf', '--specfile', 'pkg.spec'])
    
    Signed-off-by: Chenxiong Qi <cqi@redhat.com>
    
        
file modified
+48 -8
file modified
+140 -0
file modified
+17 -4