| 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 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 # Hack out upload logging.info() | 35 # Hack out upload logging.info() |
| 36 upload.logging = logging.getLogger('upload') | 36 upload.logging = logging.getLogger('upload') |
| 37 # Mac pylint choke on this line. | 37 # Mac pylint choke on this line. |
| 38 upload.logging.setLevel(logging.WARNING) # pylint: disable=E1103 | 38 upload.logging.setLevel(logging.WARNING) # pylint: disable=E1103 |
| 39 | 39 |
| 40 | 40 |
| 41 class Rietveld(object): | 41 class Rietveld(object): |
| 42 """Accesses rietveld.""" | 42 """Accesses rietveld.""" |
| 43 def __init__(self, url, email, password, extra_headers=None): | 43 def __init__(self, url, email, password, extra_headers=None): |
| 44 self.issue = None | |
| 45 self.url = url | 44 self.url = url |
| 46 if email and password: | 45 if email and password: |
| 47 get_creds = lambda: (email, password) | 46 get_creds = lambda: (email, password) |
| 48 self.rpc_server = upload.HttpRpcServer( | 47 self.rpc_server = upload.HttpRpcServer( |
| 49 self.url, | 48 self.url, |
| 50 get_creds, | 49 get_creds, |
| 51 extra_headers=extra_headers or {}) | 50 extra_headers=extra_headers or {}) |
| 52 else: | 51 else: |
| 53 self.rpc_server = upload.GetRpcServer(url, email) | 52 self.rpc_server = upload.GetRpcServer(url, email) |
| 54 self._xsrf_token = None | 53 self._xsrf_token = None |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 if retry >= (maxtries - 1): | 204 if retry >= (maxtries - 1): |
| 206 raise | 205 raise |
| 207 if not 'Name or service not known' in e.reason: | 206 if not 'Name or service not known' in e.reason: |
| 208 # Usually internal GAE flakiness. | 207 # Usually internal GAE flakiness. |
| 209 raise | 208 raise |
| 210 # If reaching this line, loop again. Uses a small backoff. | 209 # If reaching this line, loop again. Uses a small backoff. |
| 211 time.sleep(1+maxtries*2) | 210 time.sleep(1+maxtries*2) |
| 212 | 211 |
| 213 # DEPRECATED. | 212 # DEPRECATED. |
| 214 Send = get | 213 Send = get |
| OLD | NEW |