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 # Mac pylint choke on this line. | 37 upload.logging.setLevel(logging.WARNING) |
38 upload.logging.setLevel(logging.WARNING) # pylint: disable=E1103 | |
39 | 38 |
40 | 39 |
41 class Rietveld(object): | 40 class Rietveld(object): |
42 """Accesses rietveld.""" | 41 """Accesses rietveld.""" |
43 def __init__(self, url, email, password): | 42 def __init__(self, url, email, password): |
44 self.issue = None | 43 self.issue = None |
45 self.user = email | 44 self.user = email |
46 self.url = url | 45 self.url = url |
47 self._get_creds = lambda: (email, password) | 46 self._get_creds = lambda: (email, password) |
48 self._xsrf_token = None | 47 self._xsrf_token = None |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 if e.code not in (500, 502, 503): | 195 if e.code not in (500, 502, 503): |
197 raise | 196 raise |
198 except urllib2.URLError, e: | 197 except urllib2.URLError, e: |
199 if retry >= (maxtries - 1): | 198 if retry >= (maxtries - 1): |
200 raise | 199 raise |
201 if not 'Name or service not known' in e.reason: | 200 if not 'Name or service not known' in e.reason: |
202 # Usually internal GAE flakiness. | 201 # Usually internal GAE flakiness. |
203 raise | 202 raise |
204 # If reaching this line, loop again. Uses a small backoff. | 203 # If reaching this line, loop again. Uses a small backoff. |
205 time.sleep(1+maxtries*2) | 204 time.sleep(1+maxtries*2) |
OLD | NEW |