OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """ This module contains tools for running commands in a shell. """ | 6 """ This module contains tools for running commands in a shell. """ |
7 | 7 |
8 import datetime | 8 import datetime |
9 import os | 9 import os |
10 import Queue | 10 import Queue |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 timeout. """ | 46 timeout. """ |
47 pass | 47 pass |
48 | 48 |
49 | 49 |
50 def run_async(cmd, echo=None, shell=False): | 50 def run_async(cmd, echo=None, shell=False): |
51 """ Run 'cmd' in a subprocess, returning a Popen class instance referring to | 51 """ Run 'cmd' in a subprocess, returning a Popen class instance referring to |
52 that process. (Non-blocking) """ | 52 that process. (Non-blocking) """ |
53 if echo is None: | 53 if echo is None: |
54 echo = VERBOSE | 54 echo = VERBOSE |
55 if echo: | 55 if echo: |
56 print cmd | 56 print ' '.join(cmd) if isinstance(cmd, list) else cmd |
57 if 'nt' in os.name: | 57 if 'nt' in os.name: |
58 # Windows has a bad habit of opening a dialog when a console program | 58 # Windows has a bad habit of opening a dialog when a console program |
59 # crashes, rather than just letting it crash. Therefore, when a program | 59 # crashes, rather than just letting it crash. Therefore, when a program |
60 # crashes on Windows, we don't find out until the build step times out. | 60 # crashes on Windows, we don't find out until the build step times out. |
61 # This code prevents the dialog from appearing, so that we find out | 61 # This code prevents the dialog from appearing, so that we find out |
62 # immediately and don't waste time waiting around. | 62 # immediately and don't waste time waiting around. |
63 SEM_NOGPFAULTERRORBOX = 0x0002 | 63 SEM_NOGPFAULTERRORBOX = 0x0002 |
64 ctypes.windll.kernel32.SetErrorMode(SEM_NOGPFAULTERRORBOX) | 64 ctypes.windll.kernel32.SetErrorMode(SEM_NOGPFAULTERRORBOX) |
65 flags = 0x8000000 # CREATE_NO_WINDOW | 65 flags = 0x8000000 # CREATE_NO_WINDOW |
66 else: | 66 else: |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 while True: | 239 while True: |
240 try: | 240 try: |
241 return run(cmd, echo=echo, shell=shell, timeout=timeout, | 241 return run(cmd, echo=echo, shell=shell, timeout=timeout, |
242 print_timestamps=print_timestamps) | 242 print_timestamps=print_timestamps) |
243 except CommandFailedException: | 243 except CommandFailedException: |
244 if attempt >= attempts: | 244 if attempt >= attempts: |
245 raise | 245 raise |
246 print 'Command failed. Retrying in %d seconds...' % secs_between_attempts | 246 print 'Command failed. Retrying in %d seconds...' % secs_between_attempts |
247 time.sleep(secs_between_attempts) | 247 time.sleep(secs_between_attempts) |
248 attempt += 1 | 248 attempt += 1 |
OLD | NEW |