Only try keyring password once for code.google.com

If the keyring password doesn't work on the first try, it probably won't
work on the second or third. The KeyringCreds object already supports
this, we just were recreating the object at each step.

Also, if after three tries authentication to code.google.com still
fails, then the script should continue and just use un-authenticated
access to code.google.com.

BUG=158388


Review URL: https://chromiumcodereview.appspot.com/11340023

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@165446 0039d316-1c4b-4281-b951-d872f2087c98
experimental/szager/collated-output
cjhopman@chromium.org 13 years ago
parent 93477fd5fa
commit 3365f2d8ad

@ -111,11 +111,11 @@ google_code_projects = [
# Uses ClientLogin to authenticate the user for Google Code issue trackers.
def get_auth_token(email):
error = Exception()
# KeyringCreds will use the system keyring on the first try, and prompt for
# a password on the next ones.
creds = upload.KeyringCreds('code.google.com', 'code.google.com', email)
for _ in xrange(3):
email, password = (
upload.KeyringCreds('code.google.com', 'google.com', email)
.GetUserCredentials())
email, password = creds.GetUserCredentials()
url = 'https://www.google.com/accounts/ClientLogin'
data = urllib.urlencode({
'Email': email,
@ -132,9 +132,11 @@ def get_auth_token(email):
for x in response_body.split('\n') if x)
return response_dict['Auth']
except urllib2.HTTPError, e:
error = e
print e
raise error
print 'Unable to authenticate to code.google.com.'
print 'Some issues may be missing.'
return None
def username(email):
@ -378,13 +380,18 @@ class MyActivity(object):
})
opener = urllib2.build_opener()
opener.addheaders = [('Authorization', 'GoogleLogin auth=%s' %
self.google_code_auth_token)]
gcode_get = opener.open(gcode_url + '?' + gcode_data)
gcode_json = json.load(gcode_get)
gcode_get.close()
if self.google_code_auth_token:
opener.addheaders = [('Authorization', 'GoogleLogin auth=%s' %
self.google_code_auth_token)]
gcode_json = None
try:
gcode_get = opener.open(gcode_url + '?' + gcode_data)
gcode_json = json.load(gcode_get)
gcode_get.close()
except urllib2.HTTPError, _:
print 'Unable to access ' + instance['name'] + ' issue tracker.'
if 'entry' not in gcode_json['feed']:
if not gcode_json or 'entry' not in gcode_json['feed']:
return []
issues = gcode_json['feed']['entry']

Loading…
Cancel
Save