| 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 inspect | 7 import inspect |
| 8 import os | 8 import os |
| 9 import re | 9 import re |
| 10 import signal | 10 import signal |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 if input: stdin = subprocess.PIPE | 88 if input: stdin = subprocess.PIPE |
| 89 if isinstance(cmd, basestring): | 89 if isinstance(cmd, basestring): |
| 90 if enter_chroot: cmd = './enter_chroot.sh -- ' + cmd | 90 if enter_chroot: cmd = './enter_chroot.sh -- ' + cmd |
| 91 cmd_str = cmd | 91 cmd_str = cmd |
| 92 else: | 92 else: |
| 93 if enter_chroot: cmd = ['./enter_chroot.sh', '--'] + cmd | 93 if enter_chroot: cmd = ['./enter_chroot.sh', '--'] + cmd |
| 94 cmd_str = ' '.join(cmd) | 94 cmd_str = ' '.join(cmd) |
| 95 | 95 |
| 96 # Print out the command before running. | 96 # Print out the command before running. |
| 97 if print_cmd: | 97 if print_cmd: |
| 98 Info('RunCommand: %s' % cmd_str) | 98 if cwd: |
| 99 Info('RunCommand: %s in %s' % (cmd_str, cwd)) |
| 100 else: |
| 101 Info('RunCommand: %s' % cmd_str) |
| 99 cmd_result.cmd = cmd | 102 cmd_result.cmd = cmd |
| 100 | 103 |
| 101 try: | 104 try: |
| 102 proc = subprocess.Popen(cmd, cwd=cwd, stdin=stdin, stdout=stdout, | 105 proc = subprocess.Popen(cmd, cwd=cwd, stdin=stdin, stdout=stdout, |
| 103 stderr=stderr, shell=shell, env=env) | 106 stderr=stderr, shell=shell, env=env) |
| 104 if ignore_sigint: | 107 if ignore_sigint: |
| 105 old_sigint = signal.signal(signal.SIGINT, signal.SIG_IGN) | 108 old_sigint = signal.signal(signal.SIGINT, signal.SIG_IGN) |
| 106 try: | 109 try: |
| 107 (cmd_result.output, cmd_result.error) = proc.communicate(input) | 110 (cmd_result.output, cmd_result.error) = proc.communicate(input) |
| 108 finally: | 111 finally: |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 except RunCommandException as e: | 377 except RunCommandException as e: |
| 375 if not error_ok and retry_count == num_retries: | 378 if not error_ok and retry_count == num_retries: |
| 376 raise e | 379 raise e |
| 377 else: | 380 else: |
| 378 Warning(str(e)) | 381 Warning(str(e)) |
| 379 if print_cmd: | 382 if print_cmd: |
| 380 Info('PROGRAM(%s) -> RunCommand: retrying %r in dir %s' % | 383 Info('PROGRAM(%s) -> RunCommand: retrying %r in dir %s' % |
| 381 (GetCallerName(), cmd, cwd)) | 384 (GetCallerName(), cmd, cwd)) |
| 382 | 385 |
| 383 return output | 386 return output |
| OLD | NEW |