Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(713)

Unified Diff: rietveld.py

Issue 1683603002: Raise exceptions properly on HTTP errors from OAuthRpcServer (which is only used on bots) (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/rietveld_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: rietveld.py
diff --git a/rietveld.py b/rietveld.py
index 9adc9c5ca1346a99c79552dc62ae77c17c576871..2107e2e13ae967f9e5776fa16ca30984f8e1db7f 100644
--- a/rietveld.py
+++ b/rietveld.py
@@ -416,10 +416,7 @@ class Rietveld(object):
for retry in xrange(self._maxtries):
try:
logging.debug('%s' % request_path)
- result = self.rpc_server.Send(request_path, **kwargs)
- # Sometimes GAE returns a HTTP 200 but with HTTP 500 as the content.
- # How nice.
- return result
+ return self.rpc_server.Send(request_path, **kwargs)
except urllib2.HTTPError, e:
if retry >= (self._maxtries - 1):
raise
@@ -528,6 +525,11 @@ class OAuthRpcServer(object):
payload: request is a POST if not None, GET otherwise
timeout: in seconds
extra_headers: (dict)
+
+ Returns: the HTTP response body as a string
+
+ Raises:
+ urllib2.HTTPError
"""
# This method signature should match upload.py:AbstractRpcServer.Send()
method = 'GET'
@@ -543,7 +545,6 @@ class OAuthRpcServer(object):
try:
if timeout:
self._http.timeout = timeout
- # TODO(pgervais) implement some kind of retry mechanism (see upload.py).
url = self.host + request_path
if kwargs:
url += "?" + urllib.urlencode(kwargs)
@@ -572,6 +573,10 @@ class OAuthRpcServer(object):
continue
break
+ if ret[0].status != 200:
+ raise urllib2.HTTPError(
+ request_path, int(ret[0]['status']), ret[1], None, None)
+
return ret[1]
finally:
« no previous file with comments | « no previous file | tests/rietveld_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698