| OLD | NEW |
| 1 # coding: utf-8 | 1 # coding: utf-8 |
| 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 """Defines class Rietveld to easily access a rietveld instance. | 5 """Defines class Rietveld to easily access a rietveld instance. |
| 6 | 6 |
| 7 Security implications: | 7 Security implications: |
| 8 | 8 |
| 9 The following hypothesis are made: | 9 The following hypothesis are made: |
| 10 - Rietveld enforces: | 10 - Rietveld enforces: |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 logging.debug('POSTing to %s, args %s.', request_path, kwargs) | 358 logging.debug('POSTing to %s, args %s.', request_path, kwargs) |
| 359 try: | 359 try: |
| 360 # Sadly, upload.py calls ErrorExit() which does a sys.exit(1) on HTTP | 360 # Sadly, upload.py calls ErrorExit() which does a sys.exit(1) on HTTP |
| 361 # 500 in AbstractRpcServer.Send(). | 361 # 500 in AbstractRpcServer.Send(). |
| 362 old_error_exit = upload.ErrorExit | 362 old_error_exit = upload.ErrorExit |
| 363 def trap_http_500(msg): | 363 def trap_http_500(msg): |
| 364 """Converts an incorrect ErrorExit() call into a HTTPError exception.""" | 364 """Converts an incorrect ErrorExit() call into a HTTPError exception.""" |
| 365 m = re.search(r'(50\d) Server Error', msg) | 365 m = re.search(r'(50\d) Server Error', msg) |
| 366 if m: | 366 if m: |
| 367 # Fake an HTTPError exception. Cheezy. :( | 367 # Fake an HTTPError exception. Cheezy. :( |
| 368 raise urllib2.HTTPError(request_path, m.group(1), msg, None, None) | 368 raise urllib2.HTTPError( |
| 369 request_path, int(m.group(1)), msg, None, None) |
| 369 old_error_exit(msg) | 370 old_error_exit(msg) |
| 370 upload.ErrorExit = trap_http_500 | 371 upload.ErrorExit = trap_http_500 |
| 371 | 372 |
| 372 maxtries = 5 | 373 maxtries = 5 |
| 373 for retry in xrange(maxtries): | 374 for retry in xrange(maxtries): |
| 374 try: | 375 try: |
| 375 logging.debug('%s' % request_path) | 376 logging.debug('%s' % request_path) |
| 376 result = self.rpc_server.Send(request_path, **kwargs) | 377 result = self.rpc_server.Send(request_path, **kwargs) |
| 377 # Sometimes GAE returns a HTTP 200 but with HTTP 500 as the content. | 378 # Sometimes GAE returns a HTTP 200 but with HTTP 500 as the content. |
| 378 # How nice. | 379 # How nice. |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 | 514 |
| 514 def set_flag(self, issue, patchset, flag, value): # pylint:disable=R0201 | 515 def set_flag(self, issue, patchset, flag, value): # pylint:disable=R0201 |
| 515 logging.info('ReadOnlyRietveld: setting flag "%s" to "%s" for issue %d' % | 516 logging.info('ReadOnlyRietveld: setting flag "%s" to "%s" for issue %d' % |
| 516 (flag, value, issue)) | 517 (flag, value, issue)) |
| 517 ReadOnlyRietveld._local_changes.setdefault(issue, {})[flag] = value | 518 ReadOnlyRietveld._local_changes.setdefault(issue, {})[flag] = value |
| 518 | 519 |
| 519 def trigger_try_jobs( # pylint:disable=R0201 | 520 def trigger_try_jobs( # pylint:disable=R0201 |
| 520 self, issue, patchset, reason, clobber, revision, builders_and_tests): | 521 self, issue, patchset, reason, clobber, revision, builders_and_tests): |
| 521 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % | 522 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % |
| 522 (builders_and_tests, issue)) | 523 (builders_and_tests, issue)) |
| OLD | NEW |