OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # | 2 # |
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """Wrapper that does auto-retry and stats logging for command invocation. | 7 """Wrapper that does auto-retry and stats logging for command invocation. |
8 | 8 |
9 Various command line tools in use: gsutil, curl have spurious failure. | 9 Various command line tools in use: gsutil, curl have spurious failure. |
10 This wrapper will track stats to an AppEngine based service to | 10 This wrapper will track stats to an AppEngine based service to |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 142 |
143 | 143 |
144 runtime = time.time() - tm | 144 runtime = time.time() - tm |
145 accept = RunWithTimeout(LOG_TIMEOUT, LogCommand, | 145 accept = RunWithTimeout(LOG_TIMEOUT, LogCommand, |
146 options, command_id, r, cmd, | 146 options, command_id, r, cmd, |
147 p.returncode, p_stdout, p_stderr, runtime) | 147 p.returncode, p_stdout, p_stderr, runtime) |
148 if accept: | 148 if accept: |
149 return p.returncode | 149 return p.returncode |
150 if p.returncode == 0: | 150 if p.returncode == 0: |
151 return 0 | 151 return 0 |
152 print 'Command %s failed with retcode %d, try %d.' % ( | 152 print >> sys.stderr, 'Command %s failed with retcode %d, try %d.' % ( |
153 ' '.join(args), p.returncode, r + 1) | 153 ' '.join(args), p.returncode, r + 1) |
154 print 'Command %s failed %d retries, giving up.' % ( | 154 print >> sys.stderr, 'Command %s failed %d retries, giving up.' % ( |
155 ' '.join(args), options.retries) | 155 ' '.join(args), options.retries) |
156 | 156 |
157 return p.returncode | 157 return p.returncode |
158 | 158 |
159 | 159 |
160 if __name__ == '__main__': | 160 if __name__ == '__main__': |
161 sys.exit(main(sys.argv)) | 161 sys.exit(main(sys.argv)) |
OLD | NEW |