Bug 1733918 [wpt PR 31091] - [WebTransport] Make some cleanup changes for WPTs, a...
[gecko.git] / config / run-and-prefix.py
blobd78fceb7ff3f94b261c09e4bbf1921b9cd330daf
1 #!/usr/bin/env python
2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 # This script runs a process and prefixes its output with.
7 # Usage: run-and-prefix.py prefix command arg0 argv1...
9 from __future__ import absolute_import, print_function, unicode_literals
11 import os
12 import subprocess
13 import sys
15 sys.stdout = os.fdopen(sys.stdout.fileno(), "wb", 0)
16 sys.stderr = os.fdopen(sys.stderr.fileno(), "wb", 0)
18 prefix = sys.argv[1].encode("utf-8")
19 args = sys.argv[2:]
21 p = subprocess.Popen(
22 args,
23 bufsize=0,
24 stdout=subprocess.PIPE,
25 stderr=subprocess.STDOUT,
26 stdin=sys.stdin.fileno(),
27 close_fds=False,
30 while True:
31 data = p.stdout.readline()
33 if data == b"":
34 break
36 sys.stdout.write(b"%s> %s" % (prefix, data))
38 sys.exit(p.wait())