| 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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 procs = [] | 300 procs = [] |
| 301 | 301 |
| 302 for hostname in slave_hosts_cfg.SLAVE_HOSTS.iterkeys(): | 302 for hostname in slave_hosts_cfg.SLAVE_HOSTS.iterkeys(): |
| 303 if not slave_hosts_cfg.SLAVE_HOSTS[hostname].login_cmd: | 303 if not slave_hosts_cfg.SLAVE_HOSTS[hostname].login_cmd: |
| 304 results.update( | 304 results.update( |
| 305 {hostname: CommandResults.make(stderr='No procedure for login.')}) | 305 {hostname: CommandResults.make(stderr='No procedure for login.')}) |
| 306 else: | 306 else: |
| 307 procs.append((hostname, _launch_on_remote_host(hostname, cmd))) | 307 procs.append((hostname, _launch_on_remote_host(hostname, cmd))) |
| 308 | 308 |
| 309 for slavename, proc in procs: | 309 for slavename, proc in procs: |
| 310 print 'Awaiting results from %s' % slavename |
| 310 results.update(_get_remote_host_results(slavename, proc)) | 311 results.update(_get_remote_host_results(slavename, proc)) |
| 311 | 312 |
| 312 return results | 313 return results |
| 313 | 314 |
| 314 | 315 |
| 315 def parse_args(positional_args=None): | 316 def parse_args(positional_args=None): |
| 316 """Common argument parser for scripts using this module. | 317 """Common argument parser for scripts using this module. |
| 317 | 318 |
| 318 Args: | 319 Args: |
| 319 positional_args: optional list of strings; extra positional arguments to | 320 positional_args: optional list of strings; extra positional arguments to |
| (...skipping 28 matching lines...) Expand all Loading... |
| 348 setattr(options, cmd, args) | 349 setattr(options, cmd, args) |
| 349 except IndexError: | 350 except IndexError: |
| 350 parser.print_usage() | 351 parser.print_usage() |
| 351 sys.exit(1) | 352 sys.exit(1) |
| 352 return options | 353 return options |
| 353 | 354 |
| 354 | 355 |
| 355 if '__main__' == __name__: | 356 if '__main__' == __name__: |
| 356 parsed_args = parse_args() | 357 parsed_args = parse_args() |
| 357 run(parsed_args.cmd).print_results(pretty=parsed_args.pretty) | 358 run(parsed_args.cmd).print_results(pretty=parsed_args.pretty) |
| OLD | NEW |