Commit d13c75e4 authored by Denis Bilenko's avatar Denis Bilenko

record_results.py: use subprocess module instead of shell redirect

parent 388db5f4
...@@ -26,6 +26,7 @@ Usage: %prog program [args] ...@@ -26,6 +26,7 @@ Usage: %prog program [args]
""" """
import sys import sys
import os import os
import subprocess
import codecs import codecs
from os.path import abspath, dirname, join, split from os.path import abspath, dirname, join, split
try: try:
...@@ -65,20 +66,20 @@ def main(): ...@@ -65,20 +66,20 @@ def main():
del argv[0] del argv[0]
else: else:
debug = False debug = False
output_name = os.tmpnam() arg = ' '.join(argv)
arg = ' '.join(argv) + ' &> %s' % output_name
print arg print arg
returncode = os.system(arg)>>8 p = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
returncode = p.wait()
print arg, 'finished with code', returncode print arg, 'finished with code', returncode
output = codecs.open(output_name, mode='r', encoding='utf-8', errors='replace').read().replace('\x00', '?') output = p.stdout.read()
if not debug: if not debug:
if returncode==1: if returncode==1:
pass pass
elif returncode==8 and disabled_marker in output: elif returncode==8 and disabled_marker in output:
pass pass
else: else:
print "saving %s bytes of output" % len(output)
record(argv, output, returncode) record(argv, output, returncode)
os.unlink(output_name)
sys.exit(returncode) sys.exit(returncode)
if __name__=='__main__': if __name__=='__main__':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment