| OLD | NEW |
| (Empty) |
| 1 import os | |
| 2 import os.path | |
| 3 import subprocess | |
| 4 import sys | |
| 5 | |
| 6 if len(sys.argv) < 3: | |
| 7 print "Usage: %s OUTPUTFILE SCRIPTNAME ARGUMENTS" % sys.argv[0] | |
| 8 print "Re-execs the python interpreter against SCRIPTNAME with ARGS," | |
| 9 print "redirecting output to OUTPUTFILE." | |
| 10 sys.exit(1) | |
| 11 | |
| 12 abs_outputfile = os.path.abspath(sys.argv[1]) | |
| 13 abs_outputdir = os.path.dirname(abs_outputfile) | |
| 14 | |
| 15 if not os.path.isdir(abs_outputdir): | |
| 16 os.makedirs(abs_outputdir) | |
| 17 | |
| 18 ret = 0 | |
| 19 | |
| 20 with open(abs_outputfile, "w") as f: | |
| 21 ret = subprocess.Popen([sys.executable] + sys.argv[2:], stdout=f).wait() | |
| 22 | |
| 23 if ret: | |
| 24 os.remove(abs_outputfile) | |
| 25 sys.exit(ret) | |
| OLD | NEW |