Add ICU message format support
[chromium-blink-merge.git] / third_party / mesa / redirectoutput.py
blobbcd235552d09fd4db3a48f89666dfb68814185e9
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 import os
6 import os.path
7 import subprocess
8 import sys
10 if len(sys.argv) < 3:
11 print "Usage: %s OUTPUTFILE SCRIPTNAME ARGUMENTS" % sys.argv[0]
12 print "Re-execs the python interpreter against SCRIPTNAME with ARGS,"
13 print "redirecting output to OUTPUTFILE."
14 sys.exit(1)
16 abs_outputfile = os.path.abspath(sys.argv[1])
17 abs_outputdir = os.path.dirname(abs_outputfile)
19 if not os.path.isdir(abs_outputdir):
20 os.makedirs(abs_outputdir)
22 ret = 0
24 with open(abs_outputfile, "w") as f:
25 ret = subprocess.Popen([sys.executable] + sys.argv[2:], stdout=f).wait()
27 if ret:
28 os.remove(abs_outputfile)
29 sys.exit(ret)