| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 | 6 |
| 7 """Run a command and report its results in machine-readable format.""" | 7 """Run a command and report its results in machine-readable format.""" |
| 8 | 8 |
| 9 | 9 |
| 10 import collections | 10 import collections |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 166 |
| 167 def _launch_cmd(cmd): | 167 def _launch_cmd(cmd): |
| 168 """Launch the given command. Non-blocking. | 168 """Launch the given command. Non-blocking. |
| 169 | 169 |
| 170 Args: | 170 Args: |
| 171 cmd: list of strings; command to run. | 171 cmd: list of strings; command to run. |
| 172 Returns: | 172 Returns: |
| 173 subprocess.Popen instance. | 173 subprocess.Popen instance. |
| 174 """ | 174 """ |
| 175 print ' '.join(cmd) | 175 print ' '.join(cmd) |
| 176 subprocess.call(cmd) |
| 176 return subprocess.Popen(cmd, shell=False, stderr=subprocess.PIPE, | 177 return subprocess.Popen(cmd, shell=False, stderr=subprocess.PIPE, |
| 177 stdout=subprocess.PIPE) | 178 stdout=subprocess.PIPE) |
| 178 | 179 |
| 179 | 180 |
| 180 def _get_result(popen): | 181 def _get_result(popen): |
| 181 """Get the results from a running process. Blocks until the process completes. | 182 """Get the results from a running process. Blocks until the process completes. |
| 182 | 183 |
| 183 Args: | 184 Args: |
| 184 popen: subprocess.Popen instance. | 185 popen: subprocess.Popen instance. |
| 185 Returns: | 186 Returns: |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 setattr(options, cmd, args) | 354 setattr(options, cmd, args) |
| 354 except IndexError: | 355 except IndexError: |
| 355 parser.print_usage() | 356 parser.print_usage() |
| 356 sys.exit(1) | 357 sys.exit(1) |
| 357 return options | 358 return options |
| 358 | 359 |
| 359 | 360 |
| 360 if '__main__' == __name__: | 361 if '__main__' == __name__: |
| 361 parsed_args = parse_args() | 362 parsed_args = parse_args() |
| 362 run(parsed_args.cmd).print_results(pretty=parsed_args.pretty) | 363 run(parsed_args.cmd).print_results(pretty=parsed_args.pretty) |
| OLD | NEW |