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 24 matching lines...) Expand all Loading... |
35 | 35 |
36 # Hack out upload logging.info() | 36 # Hack out upload logging.info() |
37 upload.logging = logging.getLogger('upload') | 37 upload.logging = logging.getLogger('upload') |
38 # Mac pylint choke on this line. | 38 # Mac pylint choke on this line. |
39 upload.logging.setLevel(logging.WARNING) # pylint: disable=E1103 | 39 upload.logging.setLevel(logging.WARNING) # pylint: disable=E1103 |
40 | 40 |
41 | 41 |
42 class Rietveld(object): | 42 class Rietveld(object): |
43 """Accesses rietveld.""" | 43 """Accesses rietveld.""" |
44 def __init__(self, url, email, password, extra_headers=None): | 44 def __init__(self, url, email, password, extra_headers=None): |
45 self.url = url | 45 self.url = url.rstrip('/') |
46 # TODO(maruel): It's not awesome but maybe necessary to retrieve the value. | 46 # TODO(maruel): It's not awesome but maybe necessary to retrieve the value. |
47 # It happens when the presubmit check is ran out of process, the cookie | 47 # It happens when the presubmit check is ran out of process, the cookie |
48 # needed to be recreated from the credentials. Instead, it should pass the | 48 # needed to be recreated from the credentials. Instead, it should pass the |
49 # email and the cookie. | 49 # email and the cookie. |
50 self.email = email | 50 self.email = email |
51 self.password = password | 51 self.password = password |
52 if email and password: | 52 if email and password: |
53 get_creds = lambda: (email, password) | 53 get_creds = lambda: (email, password) |
54 self.rpc_server = upload.HttpRpcServer( | 54 self.rpc_server = upload.HttpRpcServer( |
55 self.url, | 55 self.url, |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 if retry >= (maxtries - 1): | 327 if retry >= (maxtries - 1): |
328 raise | 328 raise |
329 if not 'Name or service not known' in e.reason: | 329 if not 'Name or service not known' in e.reason: |
330 # Usually internal GAE flakiness. | 330 # Usually internal GAE flakiness. |
331 raise | 331 raise |
332 # If reaching this line, loop again. Uses a small backoff. | 332 # If reaching this line, loop again. Uses a small backoff. |
333 time.sleep(1+maxtries*2) | 333 time.sleep(1+maxtries*2) |
334 | 334 |
335 # DEPRECATED. | 335 # DEPRECATED. |
336 Send = get | 336 Send = get |
OLD | NEW |