OLD | NEW |
---|---|
1 # coding: utf-8 | 1 # coding: utf-8 |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 """Defines class Rietveld to easily access a rietveld instance. | 5 """Defines class Rietveld to easily access a rietveld instance. |
6 | 6 |
7 Security implications: | 7 Security implications: |
8 | 8 |
9 The following hypothesis are made: | 9 The following hypothesis are made: |
10 - Rietveld enforces: | 10 - Rietveld enforces: |
11 - Nobody else than issue owner can upload a patch set | 11 - Nobody else than issue owner can upload a patch set |
12 - Verifies the issue owner credentials when creating new issues | 12 - Verifies the issue owner credentials when creating new issues |
13 - A issue owner can't change once the issue is created | 13 - A issue owner can't change once the issue is created |
14 - A patch set cannot be modified | 14 - A patch set cannot be modified |
15 """ | 15 """ |
16 | 16 |
17 import copy | 17 import copy |
18 import json | 18 import json |
19 import logging | 19 import logging |
20 import re | 20 import re |
21 import ssl | |
21 import time | 22 import time |
22 import urllib2 | 23 import urllib2 |
23 | 24 |
24 from third_party import upload | 25 from third_party import upload |
25 import patch | 26 import patch |
26 | 27 |
27 # Hack out upload logging.info() | 28 # Hack out upload logging.info() |
28 upload.logging = logging.getLogger('upload') | 29 upload.logging = logging.getLogger('upload') |
29 # Mac pylint choke on this line. | 30 # Mac pylint choke on this line. |
30 upload.logging.setLevel(logging.WARNING) # pylint: disable=E1103 | 31 upload.logging.setLevel(logging.WARNING) # pylint: disable=E1103 |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
398 raise | 399 raise |
399 if e.code not in (500, 502, 503): | 400 if e.code not in (500, 502, 503): |
400 raise | 401 raise |
401 except urllib2.URLError, e: | 402 except urllib2.URLError, e: |
402 if retry >= (maxtries - 1): | 403 if retry >= (maxtries - 1): |
403 raise | 404 raise |
404 if (not 'Name or service not known' in e.reason and | 405 if (not 'Name or service not known' in e.reason and |
405 not 'EOF occurred in violation of protocol' in e.reason): | 406 not 'EOF occurred in violation of protocol' in e.reason): |
406 # Usually internal GAE flakiness. | 407 # Usually internal GAE flakiness. |
407 raise | 408 raise |
409 except ssl.SSLError, e: | |
M-A Ruel
2014/02/25 22:09:41
except ssl.SSLError as e:
| |
410 if retry >= (maxtries - 1): | |
411 raise | |
412 if not 'timed out' in e.reason: | |
413 raise | |
408 # If reaching this line, loop again. Uses a small backoff. | 414 # If reaching this line, loop again. Uses a small backoff. |
409 time.sleep(1+maxtries*2) | 415 time.sleep(1+maxtries*2) |
410 finally: | 416 finally: |
411 upload.ErrorExit = old_error_exit | 417 upload.ErrorExit = old_error_exit |
412 | 418 |
413 # DEPRECATED. | 419 # DEPRECATED. |
414 Send = get | 420 Send = get |
415 | 421 |
416 | 422 |
417 class CachingRietveld(Rietveld): | 423 class CachingRietveld(Rietveld): |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
529 | 535 |
530 def set_flag(self, issue, patchset, flag, value): # pylint:disable=R0201 | 536 def set_flag(self, issue, patchset, flag, value): # pylint:disable=R0201 |
531 logging.info('ReadOnlyRietveld: setting flag "%s" to "%s" for issue %d' % | 537 logging.info('ReadOnlyRietveld: setting flag "%s" to "%s" for issue %d' % |
532 (flag, value, issue)) | 538 (flag, value, issue)) |
533 ReadOnlyRietveld._local_changes.setdefault(issue, {})[flag] = value | 539 ReadOnlyRietveld._local_changes.setdefault(issue, {})[flag] = value |
534 | 540 |
535 def trigger_try_jobs( # pylint:disable=R0201 | 541 def trigger_try_jobs( # pylint:disable=R0201 |
536 self, issue, patchset, reason, clobber, revision, builders_and_tests): | 542 self, issue, patchset, reason, clobber, revision, builders_and_tests): |
537 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % | 543 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % |
538 (builders_and_tests, issue)) | 544 (builders_and_tests, issue)) |
OLD | NEW |