def run(cmd, **popen_args): """run the command, show the output, and return (stdout, stderr, returncode)""" from pgctl.subprocess import Popen, PIPE process = Popen(cmd, stdout=PIPE, stderr=PIPE, **popen_args) stdout, stderr = process.communicate() stdout, stderr = stdout.decode('UTF-8'), stderr.decode('UTF-8') show_both(stdout, stderr) return stdout, stderr, process.returncode