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 16 matching lines...) Expand all Loading... | |
27 except ImportError: | 27 except ImportError: |
28 # Import the one included in depot_tools. | 28 # Import the one included in depot_tools. |
29 sys.path.append(os.path.join(os.path.dirname(__file__), 'third_party')) | 29 sys.path.append(os.path.join(os.path.dirname(__file__), 'third_party')) |
30 import simplejson as json # pylint: disable=F0401 | 30 import simplejson as json # pylint: disable=F0401 |
31 | 31 |
32 from third_party import upload | 32 from third_party import upload |
33 import patch | 33 import patch |
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 upload.logging.setLevel(logging.WARNING) | 37 # Mac pylint chocke on this line. |
Dirk Pranke
2011/04/07 02:09:23
Nit. "Mac pylint chokes on this line"
| |
38 upload.logging.setLevel(logging.WARNING) # pylint: disable=E1103 | |
38 | 39 |
39 | 40 |
40 class Rietveld(object): | 41 class Rietveld(object): |
41 """Accesses rietveld.""" | 42 """Accesses rietveld.""" |
42 def __init__(self, url, email, password): | 43 def __init__(self, url, email, password): |
43 self.issue = None | 44 self.issue = None |
44 self.user = email | 45 self.user = email |
45 self.url = url | 46 self.url = url |
46 self._get_creds = lambda: (email, password) | 47 self._get_creds = lambda: (email, password) |
47 self._xsrf_token = None | 48 self._xsrf_token = None |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 if e.code not in (500, 502, 503): | 196 if e.code not in (500, 502, 503): |
196 raise | 197 raise |
197 except urllib2.URLError, e: | 198 except urllib2.URLError, e: |
198 if retry >= (maxtries - 1): | 199 if retry >= (maxtries - 1): |
199 raise | 200 raise |
200 if not 'Name or service not known' in e.reason: | 201 if not 'Name or service not known' in e.reason: |
201 # Usually internal GAE flakiness. | 202 # Usually internal GAE flakiness. |
202 raise | 203 raise |
203 # If reaching this line, loop again. Uses a small backoff. | 204 # If reaching this line, loop again. Uses a small backoff. |
204 time.sleep(1+maxtries*2) | 205 time.sleep(1+maxtries*2) |
OLD | NEW |