279 | 279 |
|
280 | 280 |
def run(command, timeout=None, debug=False, stdin=None, print_stdout=True,
|
281 | 281 |
print_stderr=True, callback_stdout=None, callback_stderr=None,
|
282 | |
environment=None, environment_override=None, win32resolve=True):
|
|
282 |
environment=None, environment_override=None, win32resolve=True,
|
|
283 |
working_directory=None):
|
283 | 284 |
'''Run an external process.
|
284 | 285 |
|
285 | 286 |
:param array command: Command line to be run, specified as array.
|
|
295 | 296 |
:param dict environment: The full execution environment for the command.
|
296 | 297 |
:param dict environment_override: Change environment variables from the
|
297 | 298 |
current values for command execution.
|
298 | |
:param win32resolve: If on Windows, find the appropriate executable first.
|
299 | |
This allows running of .bat, .cmd, etc. files without
|
300 | |
explicitly specifying their extension.
|
|
299 |
:param boolean win32resolve: If on Windows, find the appropriate executable
|
|
300 |
first. This allows running of .bat, .cmd, etc.
|
|
301 |
files without explicitly specifying their
|
|
302 |
extension.
|
|
303 |
:param string working_directory: If specified, run the executable from
|
|
304 |
within this working directory.
|
301 | 305 |
:return: A dictionary containing stdout, stderr (both as bytestrings),
|
302 | 306 |
runtime, exitcode, and more.
|
303 | 307 |
'''
|
|
326 | 330 |
if win32resolve and sys.platform == 'win32':
|
327 | 331 |
command = _windows_resolve(command)
|
328 | 332 |
|
329 | |
p = subprocess.Popen(command, shell=False, stdin=stdin_pipe, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
|
|
333 |
p = subprocess.Popen(command, shell=False, cwd=working_directory, env=env,
|
|
334 |
stdin=stdin_pipe, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
330 | 335 |
|
331 | 336 |
thread_pipe_pool = []
|
332 | 337 |
notifyee, notifier = Pipe(False)
|