diff --git a/webrtc/tools/barcode_tools/barcode_decoder.py b/webrtc/tools/barcode_tools/barcode_decoder.py index f74fe7e302..0bf8b5b41d 100755 --- a/webrtc/tools/barcode_tools/barcode_decoder.py +++ b/webrtc/tools/barcode_tools/barcode_decoder.py @@ -14,6 +14,10 @@ import sys import helper_functions +# Chrome browsertests will throw away stderr; avoid that output gets lost. +sys.stderr = sys.stdout + + def convert_yuv_to_png_files(yuv_file_name, yuv_frame_width, yuv_frame_height, output_directory, ffmpeg_dir=None): """Converts a YUV video file into PNG frames. @@ -47,8 +51,10 @@ def convert_yuv_to_png_files(yuv_file_name, yuv_frame_width, yuv_frame_height, helper_functions.run_shell_command( command, fail_msg='Error during YUV to PNG conversion') except helper_functions.HelperError, err: - print >> sys.stderr, 'Error executing command: %s. Error: %s' % (command, - err) + print 'Error executing command: %s. Error: %s' % (command, err) + return False + except OSError: + print ('Did not find %s. Have you installed it?' % ffmpeg_executable) return False return True @@ -101,8 +107,11 @@ def _decode_barcode_in_file(file_name, command_line_decoder): text_file.write(out) text_file.close() except helper_functions.HelperError, err: - print >> sys.stderr, 'Barcode in %s cannot be decoded.' % file_name - print >> sys.stderr, err + print 'Barcode in %s cannot be decoded.' % file_name + print err + return False + except OSError: + print ('Did not find %s. Have you installed it?' % command_line_decoder) return False return True @@ -263,14 +272,13 @@ def _main(): options.yuv_frame_height, output_directory=options.png_working_dir, ffmpeg_dir=options.ffmpeg_dir): - print >> sys.stderr, 'An error occurred converting from YUV to PNG frames.' + print 'An error occurred converting from YUV to PNG frames.' return -1 # Decode the barcodes from the PNG frames. if not decode_frames(input_directory=options.png_working_dir, zxing_dir=options.zxing_dir): - print >> sys.stderr, ('An error occurred decoding barcodes from PNG frames.' - ' Have you built the zxing C++ executable?') + print 'An error occurred decoding barcodes from PNG frames.' return -2 # Generate statistics file. diff --git a/webrtc/tools/compare_videos.py b/webrtc/tools/compare_videos.py index 5308b62917..0e0a4f6592 100755 --- a/webrtc/tools/compare_videos.py +++ b/webrtc/tools/compare_videos.py @@ -15,6 +15,9 @@ import sys SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +# Chrome browsertests will throw away stderr; avoid that output gets lost. +sys.stderr = sys.stdout + def _ParseArgs(): """Registers the command-line options.""" @@ -85,7 +88,7 @@ def main(): barcode_decoder = subprocess.Popen(cmd, stdout=sys.stdout, stderr=sys.stderr) barcode_decoder.wait() if barcode_decoder.returncode != 0: - print >> sys.stderr, 'Failed to run barcode decoder script.' + print 'Failed to run barcode decoder script.' return 1 # Run frame analyzer to compare the videos and print output. @@ -100,7 +103,7 @@ def main(): frame_analyzer = subprocess.Popen(cmd, stdout=sys.stdout, stderr=sys.stderr) frame_analyzer.wait() if frame_analyzer.returncode != 0: - print >> sys.stderr, 'Failed to run frame analyzer.' + print 'Failed to run frame analyzer.' return 1 return 0