| OLD | NEW |
| 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 """Defines class Rietveld to easily access a rietveld instance. | 4 """Defines class Rietveld to easily access a rietveld instance. |
| 5 | 5 |
| 6 Security implications: | 6 Security implications: |
| 7 | 7 |
| 8 The following hypothesis are made: | 8 The following hypothesis are made: |
| 9 - Rietveld enforces: | 9 - Rietveld enforces: |
| 10 - Nobody else than issue owner can upload a patch set | 10 - Nobody else than issue owner can upload a patch set |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 (time.time() - self._xsrf_token_time) > 30*60): | 58 (time.time() - self._xsrf_token_time) > 30*60): |
| 59 self._xsrf_token_time = time.time() | 59 self._xsrf_token_time = time.time() |
| 60 self._xsrf_token = self.get( | 60 self._xsrf_token = self.get( |
| 61 '/xsrf_token', | 61 '/xsrf_token', |
| 62 extra_headers={'X-Requesting-XSRF-Token': '1'}) | 62 extra_headers={'X-Requesting-XSRF-Token': '1'}) |
| 63 return self._xsrf_token | 63 return self._xsrf_token |
| 64 | 64 |
| 65 def get_pending_issues(self): | 65 def get_pending_issues(self): |
| 66 """Returns an array of dict of all the pending issues on the server.""" | 66 """Returns an array of dict of all the pending issues on the server.""" |
| 67 return json.loads(self.get( | 67 return json.loads(self.get( |
| 68 '/search?format=json&commit=True&closed=False&keys_only=True') | 68 '/search?format=json&commit=2&closed=3&keys_only=True&limit=1000') |
| 69 )['results'] | 69 )['results'] |
| 70 | 70 |
| 71 def close_issue(self, issue): | 71 def close_issue(self, issue): |
| 72 """Closes the Rietveld issue for this changelist.""" | 72 """Closes the Rietveld issue for this changelist.""" |
| 73 logging.info('closing issue %s' % issue) | 73 logging.info('closing issue %s' % issue) |
| 74 self.post("/%d/close" % issue, [('xsrf_token', self.xsrf_token())]) | 74 self.post("/%d/close" % issue, [('xsrf_token', self.xsrf_token())]) |
| 75 | 75 |
| 76 def get_description(self, issue): | 76 def get_description(self, issue): |
| 77 """Returns the issue's description.""" | 77 """Returns the issue's description.""" |
| 78 return self.get('/%d/description' % issue) | 78 return self.get('/%d/description' % issue) |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 if retry >= (maxtries - 1): | 204 if retry >= (maxtries - 1): |
| 205 raise | 205 raise |
| 206 if not 'Name or service not known' in e.reason: | 206 if not 'Name or service not known' in e.reason: |
| 207 # Usually internal GAE flakiness. | 207 # Usually internal GAE flakiness. |
| 208 raise | 208 raise |
| 209 # If reaching this line, loop again. Uses a small backoff. | 209 # If reaching this line, loop again. Uses a small backoff. |
| 210 time.sleep(1+maxtries*2) | 210 time.sleep(1+maxtries*2) |
| 211 | 211 |
| 212 # DEPRECATED. | 212 # DEPRECATED. |
| 213 Send = get | 213 Send = get |
| OLD | NEW |