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

Side by Side Diff: lib/cros_build_lib.py

Issue 3967002: Fix args to RunCommand (Closed) Base URL: http://git.chromium.org/git/crosutils.git
Patch Set: Fix print Created 10 years, 2 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 | « bin/cros_au_test_harness.py ('k') | 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 subprocess 9 import subprocess
10 import sys 10 import sys
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 output = '' 47 output = ''
48 48
49 # Modify defaults based on parameters. 49 # Modify defaults based on parameters.
50 if redirect_stdout: stdout = subprocess.PIPE 50 if redirect_stdout: stdout = subprocess.PIPE
51 if redirect_stderr: stderr = subprocess.PIPE 51 if redirect_stderr: stderr = subprocess.PIPE
52 if input: stdin = subprocess.PIPE 52 if input: stdin = subprocess.PIPE
53 if enter_chroot: cmd = ['./enter_chroot.sh', '--'] + cmd 53 if enter_chroot: cmd = ['./enter_chroot.sh', '--'] + cmd
54 54
55 # Print out the command before running. 55 # Print out the command before running.
56 if print_cmd: 56 if print_cmd:
57 Info('PROGRAM(%s) -> RunCommand: %s in dir %s' % 57 Info('PROGRAM(%s) -> RunCommand: %r in dir %s' %
58 (GetCallerName(), ' '.join(cmd), cwd)) 58 (GetCallerName(), cmd, cwd))
59 59
60 try: 60 try:
61 proc = subprocess.Popen(cmd, cwd=cwd, stdin=stdin, 61 proc = subprocess.Popen(cmd, cwd=cwd, stdin=stdin,
62 stdout=stdout, stderr=stderr) 62 stdout=stdout, stderr=stderr)
63 (output, error) = proc.communicate(input) 63 (output, error) = proc.communicate(input)
64 if exit_code: 64 if exit_code:
65 return proc.returncode 65 return proc.returncode
66 66
67 if not error_ok and proc.returncode: 67 if not error_ok and proc.returncode:
68 raise Exception('Command "%s" failed.\n' % (' '.join(cmd)) + 68 raise Exception('Command "%r" failed.\n' % (cmd) +
69 (error_message or error or output or '')) 69 (error_message or error or output or ''))
70 except Exception, e: 70 except Exception, e:
71 if not error_ok: 71 if not error_ok:
72 raise 72 raise
73 else: 73 else:
74 Warning(str(e)) 74 Warning(str(e))
75 75
76 return output 76 return output
77 77
78 78
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 162
163 # Strip the repository root from the path and strip first /. 163 # Strip the repository root from the path and strip first /.
164 relative_path = path_abs_path.replace(root_abs_path, '')[1:] 164 relative_path = path_abs_path.replace(root_abs_path, '')[1:]
165 165
166 if relative_path == path_abs_path: 166 if relative_path == path_abs_path:
167 raise Exception('Error: path is outside your src tree, cannot reinterpret.') 167 raise Exception('Error: path is outside your src tree, cannot reinterpret.')
168 168
169 new_path = os.path.join('/home', os.getenv('USER'), 'trunk', relative_path) 169 new_path = os.path.join('/home', os.getenv('USER'), 'trunk', relative_path)
170 return new_path 170 return new_path
171 171
OLDNEW
« no previous file with comments | « bin/cros_au_test_harness.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698