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...
13 sys
.stdout
= os
.fdopen(sys
.stdout
.fileno(), "wb", 0)
14 sys
.stderr
= os
.fdopen(sys
.stderr
.fileno(), "wb", 0)
16 prefix
= sys
.argv
[1].encode("utf-8")
22 stdout
=subprocess
.PIPE
,
23 stderr
=subprocess
.STDOUT
,
24 stdin
=sys
.stdin
.fileno(),
29 data
= p
.stdout
.readline()
34 sys
.stdout
.write(b
"%s> %s" % (prefix
, data
))