Chromium Code Reviews| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 | 90 |
| 91 Converts any CRLF into LF and strip extraneous whitespace. | 91 Converts any CRLF into LF and strip extraneous whitespace. |
| 92 """ | 92 """ |
| 93 return '\n'.join(self.get('/%d/description' % issue).strip().splitlines()) | 93 return '\n'.join(self.get('/%d/description' % issue).strip().splitlines()) |
| 94 | 94 |
| 95 def get_issue_properties(self, issue, messages): | 95 def get_issue_properties(self, issue, messages): |
| 96 """Returns all the issue's metadata as a dictionary.""" | 96 """Returns all the issue's metadata as a dictionary.""" |
| 97 url = '/api/%d' % issue | 97 url = '/api/%d' % issue |
| 98 if messages: | 98 if messages: |
| 99 url += '?messages=true' | 99 url += '?messages=true' |
| 100 data = json.loads(self.get(url)) | 100 NUM_RETRIES = 5 |
| 101 for tries in xrange(NUM_RETRIES): | |
| 102 try: | |
| 103 data = json.loads(self.get(url)) | |
|
M-A Ruel
2014/07/28 21:11:38
It'd be more sane to add a retry_404=True flag to
hinoka
2014/08/27 13:42:47
Done.
| |
| 104 except urllib2.HTTPError as e: | |
| 105 if e.code == 404: | |
| 106 # 404 might indicate datastore lag. Wait and try again. | |
| 107 if tries < NUM_RETRIES - 1: | |
| 108 time.sleep(2 ** tries) | |
| 109 continue | |
| 110 raise | |
| 111 else: | |
| 112 break | |
| 113 | |
| 101 data['description'] = '\n'.join(data['description'].strip().splitlines()) | 114 data['description'] = '\n'.join(data['description'].strip().splitlines()) |
| 102 return data | 115 return data |
| 103 | 116 |
| 104 def get_patchset_properties(self, issue, patchset): | 117 def get_patchset_properties(self, issue, patchset): |
| 105 """Returns the patchset properties.""" | 118 """Returns the patchset properties.""" |
| 106 url = '/api/%d/%d' % (issue, patchset) | 119 url = '/api/%d/%d' % (issue, patchset) |
| 107 return json.loads(self.get(url)) | 120 return json.loads(self.get(url)) |
| 108 | 121 |
| 109 def get_file_content(self, issue, patchset, item): | 122 def get_file_content(self, issue, patchset, item): |
| 110 """Returns the content of a new file. | 123 """Returns the content of a new file. |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 717 def trigger_try_jobs( # pylint:disable=R0201 | 730 def trigger_try_jobs( # pylint:disable=R0201 |
| 718 self, issue, patchset, reason, clobber, revision, builders_and_tests, | 731 self, issue, patchset, reason, clobber, revision, builders_and_tests, |
| 719 master=None): | 732 master=None): |
| 720 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % | 733 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % |
| 721 (builders_and_tests, issue)) | 734 (builders_and_tests, issue)) |
| 722 | 735 |
| 723 def trigger_distributed_try_jobs( # pylint:disable=R0201 | 736 def trigger_distributed_try_jobs( # pylint:disable=R0201 |
| 724 self, issue, patchset, reason, clobber, revision, masters): | 737 self, issue, patchset, reason, clobber, revision, masters): |
| 725 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % | 738 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % |
| 726 (masters, issue)) | 739 (masters, issue)) |
| OLD | NEW |