| OLD | NEW |
| 1 # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium OS 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 | 4 |
| 5 """ | 5 """ |
| 6 Utilities for requesting information for a gerrit server via https. | 6 Utilities for requesting information for a gerrit server via https. |
| 7 | 7 |
| 8 https://gerrit-review.googlesource.com/Documentation/rest-api.html | 8 https://gerrit-review.googlesource.com/Documentation/rest-api.html |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 reason = ('Authentication failed. Please make sure your .netrc file ' | 319 reason = ('Authentication failed. Please make sure your .netrc file ' |
| 320 'has credentials for %s' % host) | 320 'has credentials for %s' % host) |
| 321 raise GerritAuthenticationError(response.status, reason) | 321 raise GerritAuthenticationError(response.status, reason) |
| 322 | 322 |
| 323 # If response.status < 500 then the result is final; break retry loop. | 323 # If response.status < 500 then the result is final; break retry loop. |
| 324 if response.status < 500: | 324 if response.status < 500: |
| 325 break | 325 break |
| 326 # A status >=500 is assumed to be a possible transient error; retry. | 326 # A status >=500 is assumed to be a possible transient error; retry. |
| 327 http_version = 'HTTP/%s' % ('1.1' if response.version == 11 else '1.0') | 327 http_version = 'HTTP/%s' % ('1.1' if response.version == 11 else '1.0') |
| 328 msg = ( | 328 msg = ( |
| 329 'A transient error occured while querying %s:\n' | 329 'A transient error occurred while querying %s:\n' |
| 330 '%s %s %s\n' | 330 '%s %s %s\n' |
| 331 '%s %d %s' % ( | 331 '%s %d %s' % ( |
| 332 conn.host, conn.req_params['method'], conn.req_params['url'], | 332 conn.host, conn.req_params['method'], conn.req_params['url'], |
| 333 http_version, http_version, response.status, response.reason)) | 333 http_version, http_version, response.status, response.reason)) |
| 334 if TRY_LIMIT - idx > 1: | 334 if TRY_LIMIT - idx > 1: |
| 335 msg += '\n... will retry %d more times.' % (TRY_LIMIT - idx - 1) | 335 msg += '\n... will retry %d more times.' % (TRY_LIMIT - idx - 1) |
| 336 time.sleep(sleep_time) | 336 time.sleep(sleep_time) |
| 337 sleep_time = sleep_time * 2 | 337 sleep_time = sleep_time * 2 |
| 338 req_host = conn.req_host | 338 req_host = conn.req_host |
| 339 req_params = conn.req_params | 339 req_params = conn.req_params |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 username = review.get('email', jmsg.get('name', '')) | 682 username = review.get('email', jmsg.get('name', '')) |
| 683 raise GerritError(200, 'Unable to set %s label for user "%s"' | 683 raise GerritError(200, 'Unable to set %s label for user "%s"' |
| 684 ' on change %s.' % (label, username, change)) | 684 ' on change %s.' % (label, username, change)) |
| 685 jmsg = GetChangeCurrentRevision(host, change) | 685 jmsg = GetChangeCurrentRevision(host, change) |
| 686 if not jmsg: | 686 if not jmsg: |
| 687 raise GerritError( | 687 raise GerritError( |
| 688 200, 'Could not get review information for change "%s"' % change) | 688 200, 'Could not get review information for change "%s"' % change) |
| 689 elif jmsg[0]['current_revision'] != revision: | 689 elif jmsg[0]['current_revision'] != revision: |
| 690 raise GerritError(200, 'While resetting labels on change "%s", ' | 690 raise GerritError(200, 'While resetting labels on change "%s", ' |
| 691 'a new patchset was uploaded.' % change) | 691 'a new patchset was uploaded.' % change) |
| OLD | NEW |