Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Side by Side Diff: lib/cros_build_lib.py

Issue 6902129: Arbitrarily large output can't be used in an exception. (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Common python commands used by various build scripts.""" 5 """Common python commands used by various build scripts."""
6 6
7 import inspect 7 import inspect
8 import os 8 import os
9 import re 9 import re
10 import subprocess 10 import subprocess
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 break 103 break
104 104
105 if file_handle: file_handle.close() 105 if file_handle: file_handle.close()
106 106
107 # If they asked for an exit_code, give it to them on success or failure 107 # If they asked for an exit_code, give it to them on success or failure
108 if exit_code: 108 if exit_code:
109 return proc.returncode 109 return proc.returncode
110 110
111 # If the command (and all retries) failed, handle error result 111 # If the command (and all retries) failed, handle error result
112 if proc.returncode != 0 and not error_ok: 112 if proc.returncode != 0 and not error_ok:
113 if output:
114 print >> sys.stderr, output
115 sys.stderr.flush()
116
113 error_info = ('Command "%r" failed.\n' % (cmd) + 117 error_info = ('Command "%r" failed.\n' % (cmd) +
114 (error_message or error or output or '')) 118 (error_message or error or ''))
115 if log_to_file: error_info += '\nOutput logged to %s' % log_to_file 119 if log_to_file: error_info += '\nOutput logged to %s' % log_to_file
116 raise RunCommandException(error_info) 120 raise RunCommandException(error_info)
117 121
118 # return final result 122 # return final result
119 return output 123 return output
120 124
121 125
122 def RunCommandCaptureOutput(cmd, print_cmd=True, cwd=None, input=None, 126 def RunCommandCaptureOutput(cmd, print_cmd=True, cwd=None, input=None,
123 enter_chroot=False, 127 enter_chroot=False,
124 combine_stdout_stderr=True, 128 combine_stdout_stderr=True,
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 return os.path.join(GetCrosUtilsPath(source_dir_path), 'bin') 359 return os.path.join(GetCrosUtilsPath(source_dir_path), 'bin')
356 360
357 361
358 def IsInsideChroot(): 362 def IsInsideChroot():
359 """Returns True if we are inside chroot.""" 363 """Returns True if we are inside chroot."""
360 return os.path.exists('/etc/debian_chroot') 364 return os.path.exists('/etc/debian_chroot')
361 365
362 366
363 # TODO(sosa): Remove once all callers use method. 367 # TODO(sosa): Remove once all callers use method.
364 CROSUTILS_DIRECTORY = GetCrosUtilsPath(True) 368 CROSUTILS_DIRECTORY = GetCrosUtilsPath(True)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698