Index: python-launchpadlib-1.9.9/src/launchpadlib/credentials.py =================================================================== --- python-launchpadlib-1.9.9.orig/src/launchpadlib/credentials.py 2011-08-12 16:03:32.135963413 +0200 +++ python-launchpadlib-1.9.9/src/launchpadlib/credentials.py 2011-08-12 16:25:06.104003055 +0200 @@ -31,7 +31,9 @@ from cStringIO import StringIO import httplib2 import os +from select import select import stat +from sys import stdin import time from urllib import urlencode from urlparse import urljoin @@ -500,7 +502,10 @@ themselves. """ - WAITING_FOR_USER = "The authorization page:\n (%s)\nshould be opening in your browser. Use your browser to authorize\nthis program to access Launchpad on your behalf. \n\nWaiting to hear from Launchpad about your decision..." + WAITING_FOR_USER = "The authorization page:\n (%s)\nshould be opening in your browser. Use your browser to authorize\nthis program to access Launchpad on your behalf." + TIMEOUT_MESSAGE = "Press any key to continue or wait (%d) seconds..." + TIMEOUT = 5 + WAITING_FOR_LAUNCHPAD = "Waiting to hear from Launchpad about your decision..." def __init__(self, service_root, application_name, consumer_name=None, credential_save_failed=None, allow_access_levels=None): @@ -536,8 +541,15 @@ """Have the end-user authorize the token in their browser.""" authorization_url = self.authorization_url(request_token) - webbrowser.open(authorization_url) self.output(self.WAITING_FOR_USER % authorization_url) + self.output(self.TIMEOUT_MESSAGE % self.TIMEOUT) + # Wait a little time before attempting to launch browser, + # give users the chance to press a key to skip it anyway. + rlist, _, _ = select([stdin], [], [], self.TIMEOUT) + if rlist: + stdin.readline() + self.output(self.WAITING_FOR_LAUNCHPAD) + webbrowser.open(authorization_url) while credentials.access_token is None: time.sleep(access_token_poll_time) try: