| 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 subprocess | 9 import subprocess |
| 10 import sys | 10 import sys |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 stdout=stdout, stderr=stderr) | 74 stdout=stdout, stderr=stderr) |
| 75 (output, error) = proc.communicate(input) | 75 (output, error) = proc.communicate(input) |
| 76 if exit_code and retry_count == num_retries: | 76 if exit_code and retry_count == num_retries: |
| 77 return proc.returncode | 77 return proc.returncode |
| 78 | 78 |
| 79 if proc.returncode == 0: | 79 if proc.returncode == 0: |
| 80 break | 80 break |
| 81 | 81 |
| 82 raise RunCommandException('Command "%r" failed.\n' % (cmd) + | 82 raise RunCommandException('Command "%r" failed.\n' % (cmd) + |
| 83 (error_message or error or output or '')) | 83 (error_message or error or output or '')) |
| 84 except Exception, e: | 84 except RunCommandException as e: |
| 85 if not error_ok and retry_count == num_retries: | 85 if not error_ok and retry_count == num_retries: |
| 86 raise RunCommandException(e) | 86 raise e |
| 87 else: | 87 else: |
| 88 Warning(str(e)) | 88 Warning(str(e)) |
| 89 if print_cmd: | 89 if print_cmd: |
| 90 Info('PROGRAM(%s) -> RunCommand: retrying %r in dir %s' % | 90 Info('PROGRAM(%s) -> RunCommand: retrying %r in dir %s' % |
| 91 (GetCallerName(), cmd, cwd)) | 91 (GetCallerName(), cmd, cwd)) |
| 92 | 92 |
| 93 return output | 93 return output |
| 94 | 94 |
| 95 | 95 |
| 96 def RunCommandCaptureOutput(cmd, print_cmd=True, cwd=None, input=None, | 96 def RunCommandCaptureOutput(cmd, print_cmd=True, cwd=None, input=None, |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 root_abs_path = os.path.abspath(root_path) | 232 root_abs_path = os.path.abspath(root_path) |
| 233 | 233 |
| 234 # Strip the repository root from the path and strip first /. | 234 # Strip the repository root from the path and strip first /. |
| 235 relative_path = path_abs_path.replace(root_abs_path, '')[1:] | 235 relative_path = path_abs_path.replace(root_abs_path, '')[1:] |
| 236 | 236 |
| 237 if relative_path == path_abs_path: | 237 if relative_path == path_abs_path: |
| 238 raise Exception('Error: path is outside your src tree, cannot reinterpret.') | 238 raise Exception('Error: path is outside your src tree, cannot reinterpret.') |
| 239 | 239 |
| 240 new_path = os.path.join('/home', os.getenv('USER'), 'trunk', relative_path) | 240 new_path = os.path.join('/home', os.getenv('USER'), 'trunk', relative_path) |
| 241 return new_path | 241 return new_path |
| OLD | NEW |