From 77ba172b82adc834a026c134e5376c8350712b36 Mon Sep 17 00:00:00 2001 From: "maruel@chromium.org" Date: Fri, 20 Nov 2009 16:48:29 +0000 Subject: [PATCH] Implement a workaround for the remaining HOSTED accounts. TEST=upload always work whatever the case BUG=none Review URL: http://codereview.chromium.org/418010 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@32617 0039d316-1c4b-4281-b951-d872f2087c98 --- upload.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/upload.py b/upload.py index d85fea7427..7d61128470 100755 --- a/upload.py +++ b/upload.py @@ -226,6 +226,35 @@ class AbstractRpcServer(object): return response_dict["Auth"] except urllib2.HTTPError, e: if e.code == 403: + # Try a temporary workaround. + if self.host.endswith(".google.com"): + account_type = "HOSTED" + req = self._CreateRequest( + url="https://www.google.com/accounts/ClientLogin", + data=urllib.urlencode({ + "Email": email, + "Passwd": password, + "service": "ah", + "source": "rietveld-codereview-upload", + "accountType": account_type, + }), + ) + try: + response = self.opener.open(req) + response_body = response.read() + response_dict = dict(x.split("=") + for x in response_body.split("\n") if x) + return response_dict["Auth"] + except urllib2.HTTPError, e: + if e.code == 403: + body = e.read() + response_dict = dict(x.split("=", 1) for x in body.split("\n") + if x) + raise ClientLoginError(req.get_full_url(), e.code, e.msg, + e.headers, response_dict) + else: + raise + body = e.read() response_dict = dict(x.split("=", 1) for x in body.split("\n") if x) raise ClientLoginError(req.get_full_url(), e.code, e.msg,