From: Ira W. Snyder Date: Wed, 7 May 2014 01:07:15 +0000 (-0700) Subject: PAR2Set/utils: add the ability to redirect stdout X-Git-Url: https://www.irasnyder.com/gitweb/?p=rarslave2.git;a=commitdiff_plain;h=d428502df7b8e948704f5a34e3b457510e9fa2a3;hp=de371c2371aea2cbaaaa30cb14435641b3426613;ds=inline PAR2Set/utils: add the ability to redirect stdout The subprocess module supports redirecting stdout to an open file descriptor. Expose this in our wrapper. --- diff --git a/PAR2Set/utils.py b/PAR2Set/utils.py index 8cd9408..242f4c5 100644 --- a/PAR2Set/utils.py +++ b/PAR2Set/utils.py @@ -93,11 +93,12 @@ def hasAMatch(regex, iterateable, ignoreCase=True): # Run the specified command-list in the given directory # @cmd a list formatted for the subprocess module # @directory the directory in which to run the command +# @stdout the stdout file descriptor, following the rules of the subprocess module # @return the status code returned by the command # # Exceptions: # subprocess.CalledProcessError when the called process return code is not 0 -def runCommand(cmd, directory): +def runCommand(cmd, directory, stdout=None): logging.debug('===== BEGIN runCommand() DEBUG =====') logging.debug('Directory: %s' % directory) @@ -106,7 +107,7 @@ def runCommand(cmd, directory): logging.debug('-> %s' % arg) logging.debug('===== END runCommand() DEBUG =====') - return subprocess.check_call(cmd, cwd=directory) + return subprocess.check_call(cmd, cwd=directory, stdout=stdout) ################################################################################