| 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 errno |
| 18 import json | 19 import json |
| 19 import logging | 20 import logging |
| 20 import re | 21 import re |
| 22 import socket |
| 21 import ssl | 23 import ssl |
| 24 import sys |
| 22 import time | 25 import time |
| 23 import urllib | 26 import urllib |
| 24 import urllib2 | 27 import urllib2 |
| 25 import urlparse | 28 import urlparse |
| 26 | 29 |
| 27 import patch | 30 import patch |
| 28 | 31 |
| 29 from third_party import upload | 32 from third_party import upload |
| 30 import third_party.oauth2client.client as oa2client | 33 import third_party.oauth2client.client as oa2client |
| 31 from third_party import httplib2 | 34 from third_party import httplib2 |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 raise | 425 raise |
| 423 flake_codes = [500, 502, 503] | 426 flake_codes = [500, 502, 503] |
| 424 if retry_on_404: | 427 if retry_on_404: |
| 425 flake_codes.append(404) | 428 flake_codes.append(404) |
| 426 if e.code not in flake_codes: | 429 if e.code not in flake_codes: |
| 427 raise | 430 raise |
| 428 except urllib2.URLError, e: | 431 except urllib2.URLError, e: |
| 429 if retry >= (self._maxtries - 1): | 432 if retry >= (self._maxtries - 1): |
| 430 raise | 433 raise |
| 431 if (not 'Name or service not known' in e.reason and | 434 if (not 'Name or service not known' in e.reason and |
| 432 not 'EOF occurred in violation of protocol' in e.reason): | 435 not 'EOF occurred in violation of protocol' in e.reason and |
| 436 # On windows we hit weird bug http://crbug.com/537417 |
| 437 # with message '[Errno 10060] A connection attempt failed...' |
| 438 not (sys.platform.startswith('win') and |
| 439 isinstance(e.reason, socket.error) and |
| 440 e.reason.errno == errno.ETIMEDOUT |
| 441 ) |
| 442 ): |
| 433 # Usually internal GAE flakiness. | 443 # Usually internal GAE flakiness. |
| 434 raise | 444 raise |
| 435 except ssl.SSLError, e: | 445 except ssl.SSLError, e: |
| 436 if retry >= (self._maxtries - 1): | 446 if retry >= (self._maxtries - 1): |
| 437 raise | 447 raise |
| 438 if not 'timed out' in str(e): | 448 if not 'timed out' in str(e): |
| 439 raise | 449 raise |
| 440 # If reaching this line, loop again. Uses a small backoff. | 450 # If reaching this line, loop again. Uses a small backoff. |
| 441 time.sleep(min(10, 1+retry*2)) | 451 time.sleep(min(10, 1+retry*2)) |
| 442 finally: | 452 finally: |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 self, issue, patchset, reason, clobber, revision, builders_and_tests, | 727 self, issue, patchset, reason, clobber, revision, builders_and_tests, |
| 718 master=None, category='cq'): | 728 master=None, category='cq'): |
| 719 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % | 729 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % |
| 720 (builders_and_tests, issue)) | 730 (builders_and_tests, issue)) |
| 721 | 731 |
| 722 def trigger_distributed_try_jobs( # pylint:disable=R0201 | 732 def trigger_distributed_try_jobs( # pylint:disable=R0201 |
| 723 self, issue, patchset, reason, clobber, revision, masters, | 733 self, issue, patchset, reason, clobber, revision, masters, |
| 724 category='cq'): | 734 category='cq'): |
| 725 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % | 735 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % |
| 726 (masters, issue)) | 736 (masters, issue)) |
| OLD | NEW |