Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame^] | 1 | #!/usr/bin/env python3 |
| 2 | # |
| 3 | # Copyright (c) 2019, Arm Limited. All rights reserved. |
| 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | # |
| 7 | |
| 8 | import subprocess |
| 9 | |
| 10 | def exec_prog(prog, args=[], out=None, out_text_mode=False): |
| 11 | # Build the command line to execute |
| 12 | cmd = [ prog ] + args |
| 13 | |
| 14 | # Spawn process. |
| 15 | # Note: The standard error output is captured into the same file handle as |
| 16 | # for stdout. |
| 17 | process = subprocess.Popen(cmd, stdout=out, stderr=subprocess.STDOUT, |
| 18 | universal_newlines=out_text_mode, bufsize=0) |
| 19 | print("Spawned process with PID %u" % process.pid) |
| 20 | return process |