pbcommand Engine

Util functions for calling external commands

pbcommand.engine.run_cmd(cmd, stdout_fh, stderr_fh, shell=True, time_out=None, env=None, executable='/bin/bash')[source]

Run external command

Param:cmd: External command
Parameters:time_out (None | int) – Timeout in seconds.
Returns:ExtCmdResult

This could all be bundled into a context manager

with RunCommand(‘/path/stdout’, ‘/path/to/stderr’) as r:
r.exe(“echo ‘exe1’) r.exe(“echo ‘exe2’) result = r.get_result() # close the file handles
class pbcommand.engine.ExtCmdResult(exit_code, cmd, run_time)

Create new instance of ExtCmdResult(exit_code, cmd, run_time)

cmd

Alias for field number 1

exit_code

Alias for field number 0

run_time

Alias for field number 2