Chromium Code Reviews| Index: third_party/gsutil/gslib/commands/config.py |
| diff --git a/third_party/gsutil/gslib/commands/config.py b/third_party/gsutil/gslib/commands/config.py |
| index 5e353ff3c8c899d9db7eb5453ce705d82ed52efe..3eeed7993304b978ba0c20b0ecc6050d55c02bbe 100644 |
| --- a/third_party/gsutil/gslib/commands/config.py |
| +++ b/third_party/gsutil/gslib/commands/config.py |
| @@ -435,7 +435,7 @@ class ConfigCommand(Command): |
| return os.fdopen(fd, 'w') |
| def _WriteBotoConfigFile(self, config_file, use_oauth2=True, |
| - launch_browser=True, oauth2_scopes=[SCOPE_FULL_CONTROL]): |
| + oauth2_scopes=[SCOPE_FULL_CONTROL]): |
| """Creates a boto config file interactively. |
| Needed credentials are obtained interactively, either by asking the user for |
| @@ -462,7 +462,7 @@ class ConfigCommand(Command): |
| if use_oauth2: |
| oauth2_refresh_token = oauth2_helper.OAuth2ApprovalFlow( |
| oauth2_helper.OAuth2ClientFromBotoConfig(boto.config), |
| - oauth2_scopes, launch_browser) |
| + oauth2_scopes) |
| else: |
| got_creds = False |
| for provider in provider_map: |
| @@ -540,49 +540,15 @@ 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 |
| # you set in the API Console. Either of these defaults can be overridden |
| # by specifying the -p option to the 'mb' and 'ls' commands. |
| """ |
| - if default_project_id: |
|
M-A Ruel
2014/04/02 21:29:43
this change is not necessary.
Ryan Tseng
2014/04/02 22:07:03
I could leave it in but it will be unreachable cod
|
| - config_file.write('%sdefault_project_id = %s\n\n\n' % |
| - (project_id_section_prelude, default_project_id)) |
| - else: |
| - sys.stderr.write('No default project ID entered. You will need to edit ' |
| - 'the default_project_id value\nin your boto config file ' |
| - 'before using "gsutil ls gs://" or "mb" commands' |
| - 'with the\ndefault API version (2).\n') |
| - config_file.write('%s#default_project_id = <value>\n\n\n' % |
| - project_id_section_prelude) |
| + config_file.write('%sdefault_project_id = %s\n\n\n' % |
| + (project_id_section_prelude, default_project_id)) |
| # Write the config file OAuth2 section. |
| config_file.write(CONFIG_OAUTH2_CONFIG_CONTENT) |
| @@ -623,8 +589,8 @@ class ConfigCommand(Command): |
| if output_file_name is None: |
| # Check to see if a default config file name is requested via |
| # environment variable. If so, use it, otherwise use the hard-coded |
| - # default file. Then use the default config file name, if it doesn't |
|
M-A Ruel
2014/04/02 21:29:43
I'd recommend to not change third party whitespace
Ryan Tseng
2014/04/02 22:07:03
Done.
|
| - # exist or can be moved out of the way without clobbering an existing |
| + # default file. Then use the default config file name, if it doesn't |
| + # exist or can be moved out of the way without clobbering an existing |
| # backup file. |
| boto_config_from_env = os.environ.get('BOTO_CONFIG', None) |
| if boto_config_from_env: |
| @@ -656,16 +622,12 @@ 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) |
| try: |
| self._WriteBotoConfigFile(output_file, use_oauth2=use_oauth2, |
| - launch_browser=launch_browser, oauth2_scopes=scopes) |
| + oauth2_scopes=scopes) |
| except Exception, e: |
| user_aborted = isinstance(e, AbortException) |
| if user_aborted: |
| @@ -684,9 +646,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 |