Commit d5a1ab12 authored by hinoka@chromium.org's avatar hinoka@chromium.org

Remove prompt for default project ID

The "What is your project ID" has confused about every user of gsutil that I've
talked to, and isn't even useful in the context of download_from_google_storage
because its only good for "mb" on a bucket and "ls" without specifying a bucket,
neither of which this version of gsutil should ever do.

This CL:
* Removes the prompt for project ID
* Removes the 2 second delay which was meant for autolaunching a browser
  * We don't want this behavior anyways because most of our devs have multiple
    browser profiles open and they need to paste the URL into the correct profile.
* Removes support to autolaunch a broswer.
* Removes a lot of the extra messages.  The prompt now looks like:
===
$ download_from_google_storage -g
Please navigate your browser to the following URL:
https://accounts.google.com/o/oauth2/auth?.....

Enter the authorization code: <code>

Boto config file "/usr/local/google/home/hinoka/.boto.depot_tools" created.
$ 
===
BUG=351015

Review URL: https://codereview.chromium.org/222973002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@267973 0039d316-1c4b-4281-b951-d872f2087c98
parent ce2fccbd
......@@ -19,5 +19,7 @@ Modifications:
* Added and imports gsutil/plugins/sso_auth.py to support prodaccess
based authentication.
* Added flag to bypass prodaccess authentication.
* Remove autolaunching the browser during gsutil config.
* Remove prompt for default project ID (Defaults to "0" now).
Full license is in the COPYING file.
......@@ -540,33 +540,7 @@ class ConfigCommand(Command):
config_file.write('default_api_version = %d\n' % api_version)
# Write the config file GSUtil section that includes the default
# project ID input from the user.
if launch_browser:
sys.stdout.write(
'Attempting to launch a browser to open the Google API console at '
'URL: %s\n\n'
'[Note: due to a Python bug, you may see a spurious error message '
'"object is not\n callable [...] in [...] Popen.__del__" which can '
'be ignored.]\n\n' % GOOG_API_CONSOLE_URI)
sys.stdout.write(
'In your browser you should see the API Console. Click "Storage" and '
'look for the value under "Identifying your project\n\n')
if not webbrowser.open(GOOG_API_CONSOLE_URI, new=1, autoraise=True):
sys.stdout.write(
'Launching browser appears to have failed; please navigate a '
'browser to the following URL:\n%s\n' % GOOG_API_CONSOLE_URI)
# Short delay; webbrowser.open on linux insists on printing out a message
# which we don't want to run into the prompt for the auth code.
time.sleep(2)
else:
sys.stdout.write(
'\nPlease navigate your browser to %s,\nthen click "Services" on the '
'left side panel and ensure you have Google Cloud\nStorage'
'activated, then click "Google Cloud Storage" on the left side '
'panel and\nfind the "x-goog-project-id" on that page.\n' %
GOOG_API_CONSOLE_URI)
default_project_id = raw_input('What is your project-id? ')
default_project_id = '0'
project_id_section_prelude = """
# 'default_project_id' specifies the default Google Cloud Storage project ID to
# use with the 'mb' and 'ls' commands. If defined it overrides the default value
......@@ -656,10 +630,6 @@ class ConfigCommand(Command):
output_file = sys.stdout
else:
output_file = self._OpenConfigFile(output_file_name)
sys.stderr.write(
'This script will create a boto config file at\n%s\ncontaining your '
'credentials, based on your responses to the following questions.\n\n'
% output_file_name)
# Catch ^C so we can restore the backup.
signal.signal(signal.SIGINT, cleanup_handler)
......@@ -684,9 +654,7 @@ class ConfigCommand(Command):
if output_file_name != '-':
output_file.close()
sys.stderr.write(
'\nBoto config file "%s" created.\nIf you need to use a proxy to '
'use a proxy to access the Internet please see the instructions in '
'that file.\n' % output_file_name)
'\nBoto config file "%s" created.\n' % output_file_name)
return 0
......
......@@ -86,21 +86,14 @@ def OAuth2ApprovalFlow(oauth2_client, scopes, launch_browser=False):
'callable [...] in [...] Popen.__del__" which can be ignored.]\n\n' % approval_url)
else:
sys.stdout.write(
'Please navigate your browser to the following URL:\n%s\n' %
'Please navigate your browser to the following URL:\n%s\n\n' %
approval_url)
sys.stdout.write(
'In your browser you should see a page that requests you to authorize '
'gsutil to access\nGoogle Cloud Storage on your behalf. After you '
'approve, an authorization code will be displayed.\n\n')
if (launch_browser and
not webbrowser.open(approval_url, new=1, autoraise=True)):
sys.stdout.write(
'Launching browser appears to have failed; please navigate a browser '
'to the following URL:\n%s\n' % approval_url)
# Short delay; webbrowser.open on linux insists on printing out a message
# which we don't want to run into the prompt for the auth code.
time.sleep(2)
code = raw_input('Enter the authorization code: ')
refresh_token, access_token = oauth2_client.ExchangeAuthorizationCode(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment