(command, input=None, cwd=None, shell=False, raiseOnError=False)
return CommandOutput(proc.returncode, stdout, stderr)
Executes a child process and captures its output
Executes a child process and captures its output
Executes a child process and captures its output
def capture(command, input=None, cwd=None, shell=False, raiseOnError=False):
		"""
		Executes a child process and captures its output
		"""
		
		# If verbose output is enabled, print the command that will be executed
		Utility._printCommand(command)
		
		# Attempt to execute the child process
		proc = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd, shell=shell, universal_newlines=True)
		(stdout, stderr) = proc.communicate(input)
		
		# If the child process failed and we were asked to raise an exception, do so
		if raiseOnError == True and proc.returncode != 0:
			raise Exception(
				'child process ' + str(command) +
				' failed with exit code ' + str(proc.returncode) +
				'\nstdout: "' + stdout + '"' +
				'\nstderr: "' + stderr + '"'
			)
		
		return CommandOutput(proc.returncode, stdout, stderr)
def capture ( command , input = None , cwd = None , shell = False , raiseOnError = False ) : # If verbose output is enabled, print the command that will be executed Utility . _printCommand ( command ) # Attempt to execute the child process proc = subprocess . Popen ( command , stdin = subprocess . PIPE , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = cwd , shell = shell , universal_newlines = True ) ( stdout , stderr ) = proc . communicate ( input ) # If the child process failed and we were asked to raise an exception, do so if raiseOnError == True and proc . returncode != 0 : raise Exception ( 'child process ' + str ( command ) + ' failed with exit code ' + str ( proc . returncode ) + '\nstdout: "' + stdout + '"' + '\nstderr: "' + stderr + '"' ) return CommandOutput ( proc . returncode , stdout , stderr )