OLD | NEW |
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 os | 7 import os |
8 import re | 8 import re |
9 import subprocess | 9 import subprocess |
10 import sys | 10 import sys |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 else: | 71 else: |
72 if enter_chroot: cmd = ['./enter_chroot.sh', '--'] + cmd | 72 if enter_chroot: cmd = ['./enter_chroot.sh', '--'] + cmd |
73 cmd_str = ' '.join(cmd) | 73 cmd_str = ' '.join(cmd) |
74 | 74 |
75 # Print out the command before running. | 75 # Print out the command before running. |
76 if print_cmd: | 76 if print_cmd: |
77 Info('RunCommand: %s' % cmd_str) | 77 Info('RunCommand: %s' % cmd_str) |
78 cmd_result.cmd = cmd_str | 78 cmd_result.cmd = cmd_str |
79 | 79 |
80 try: | 80 try: |
81 proc = subprocess.Popen(cmd_str, cwd=cwd, stdin=stdin, | 81 proc = subprocess.Popen(cmd, cwd=cwd, stdin=stdin, stdout=stdout, |
82 stdout=stdout, stderr=stderr, | 82 stderr=stderr, shell=shell) |
83 shell=shell) | |
84 (cmd_result.output, cmd_result.error) = proc.communicate(input) | 83 (cmd_result.output, cmd_result.error) = proc.communicate(input) |
85 if exit_code: | 84 if exit_code: |
86 cmd_result.returncode = proc.returncode | 85 cmd_result.returncode = proc.returncode |
87 | 86 |
88 if not error_ok and proc.returncode: | 87 if not error_ok and proc.returncode: |
89 msg = ('Command "%s" failed.\n' % cmd_str + | 88 msg = ('Command "%s" failed.\n' % cmd_str + |
90 (error_message or cmd_result.error or cmd_result.output or '')) | 89 (error_message or cmd_result.error or cmd_result.output or '')) |
91 raise RunCommandError(msg) | 90 raise RunCommandError(msg) |
92 # TODO(sosa): is it possible not to use the catch-all Exception here? | 91 # TODO(sosa): is it possible not to use the catch-all Exception here? |
93 except Exception, e: | 92 except Exception, e: |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 Returns: | 242 Returns: |
244 a string: absolute path to output directory. | 243 a string: absolute path to output directory. |
245 """ | 244 """ |
246 src_root = GetSrcRoot() | 245 src_root = GetSrcRoot() |
247 rel_path = 'build/images/%s' % board | 246 rel_path = 'build/images/%s' % board |
248 # ASSUME: --build_attempt always sets to 1 | 247 # ASSUME: --build_attempt always sets to 1 |
249 version_str = '-'.join([cros_version, 'a1']) | 248 version_str = '-'.join([cros_version, 'a1']) |
250 output_dir = os.path.join(os.path.dirname(src_root), rel_path, version_str) | 249 output_dir = os.path.join(os.path.dirname(src_root), rel_path, version_str) |
251 Info ('output_dir = %s' % output_dir) | 250 Info ('output_dir = %s' % output_dir) |
252 return output_dir | 251 return output_dir |
OLD | NEW |