| 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 |  | 
|   22 import time |   21 import time | 
|   23 import urllib2 |   22 import urllib2 | 
|   24  |   23  | 
|   25 from third_party import upload |   24 from third_party import upload | 
|   26 import patch |   25 import patch | 
|   27  |   26  | 
|   28 # Hack out upload logging.info() |   27 # Hack out upload logging.info() | 
|   29 upload.logging = logging.getLogger('upload') |   28 upload.logging = logging.getLogger('upload') | 
|   30 # Mac pylint choke on this line. |   29 # Mac pylint choke on this line. | 
|   31 upload.logging.setLevel(logging.WARNING)  # pylint: disable=E1103 |   30 upload.logging.setLevel(logging.WARNING)  # pylint: disable=E1103 | 
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  399             raise |  398             raise | 
|  400           if e.code not in (500, 502, 503): |  399           if e.code not in (500, 502, 503): | 
|  401             raise |  400             raise | 
|  402         except urllib2.URLError, e: |  401         except urllib2.URLError, e: | 
|  403           if retry >= (maxtries - 1): |  402           if retry >= (maxtries - 1): | 
|  404             raise |  403             raise | 
|  405           if (not 'Name or service not known' in e.reason and |  404           if (not 'Name or service not known' in e.reason and | 
|  406               not 'EOF occurred in violation of protocol' in e.reason): |  405               not 'EOF occurred in violation of protocol' in e.reason): | 
|  407             # Usually internal GAE flakiness. |  406             # Usually internal GAE flakiness. | 
|  408             raise |  407             raise | 
|  409         except ssl.SSLError, e: |  | 
|  410           if retry >= (maxtries - 1): |  | 
|  411             raise |  | 
|  412           if not 'timed out' in e.reason: |  | 
|  413             raise |  | 
|  414         # If reaching this line, loop again. Uses a small backoff. |  408         # If reaching this line, loop again. Uses a small backoff. | 
|  415         time.sleep(1+maxtries*2) |  409         time.sleep(1+maxtries*2) | 
|  416     finally: |  410     finally: | 
|  417       upload.ErrorExit = old_error_exit |  411       upload.ErrorExit = old_error_exit | 
|  418  |  412  | 
|  419   # DEPRECATED. |  413   # DEPRECATED. | 
|  420   Send = get |  414   Send = get | 
|  421  |  415  | 
|  422  |  416  | 
|  423 class CachingRietveld(Rietveld): |  417 class CachingRietveld(Rietveld): | 
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  535  |  529  | 
|  536   def set_flag(self, issue, patchset, flag, value):  # pylint:disable=R0201 |  530   def set_flag(self, issue, patchset, flag, value):  # pylint:disable=R0201 | 
|  537     logging.info('ReadOnlyRietveld: setting flag "%s" to "%s" for issue %d' % |  531     logging.info('ReadOnlyRietveld: setting flag "%s" to "%s" for issue %d' % | 
|  538         (flag, value, issue)) |  532         (flag, value, issue)) | 
|  539     ReadOnlyRietveld._local_changes.setdefault(issue, {})[flag] = value |  533     ReadOnlyRietveld._local_changes.setdefault(issue, {})[flag] = value | 
|  540  |  534  | 
|  541   def trigger_try_jobs(  # pylint:disable=R0201 |  535   def trigger_try_jobs(  # pylint:disable=R0201 | 
|  542       self, issue, patchset, reason, clobber, revision, builders_and_tests): |  536       self, issue, patchset, reason, clobber, revision, builders_and_tests): | 
|  543     logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % |  537     logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % | 
|  544         (builders_and_tests, issue)) |  538         (builders_and_tests, issue)) | 
| OLD | NEW |