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

Unified Diff: my_activity.py

Issue 11340023: Only try keyring password once for code.google.com (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 8 years, 2 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: my_activity.py
diff --git a/my_activity.py b/my_activity.py
index 540af78d18bf89ea0af1c4ba8abcb834611ad105..022489b51605b0febdeaf1b5dce35f25a396b795 100755
--- a/my_activity.py
+++ b/my_activity.py
@@ -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']
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698