| OLD | NEW |
| 1 # Copyright 2011 Google Inc. All Rights Reserved. | 1 # Copyright 2011 Google Inc. All Rights Reserved. |
| 2 # | 2 # |
| 3 # Licensed under the Apache License, Version 2.0 (the "License"); | 3 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 # you may not use this file except in compliance with the License. | 4 # you may not use this file except in compliance with the License. |
| 5 # You may obtain a copy of the License at | 5 # You may obtain a copy of the License at |
| 6 # | 6 # |
| 7 # http://www.apache.org/licenses/LICENSE-2.0 | 7 # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 # | 8 # |
| 9 # Unless required by applicable law or agreed to in writing, software | 9 # Unless required by applicable law or agreed to in writing, software |
| 10 # distributed under the License is distributed on an "AS IS" BASIS, | 10 # distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 raise CommandException( | 587 raise CommandException( |
| 588 'OAuth2 is only supported when running under Python 2.6 or later\n' | 588 'OAuth2 is only supported when running under Python 2.6 or later\n' |
| 589 '(unless additional dependencies are installed, ' | 589 '(unless additional dependencies are installed, ' |
| 590 'see README for details);\n' | 590 'see README for details);\n' |
| 591 'you are running Python %s.\nUse "gsutil config -a" to create a ' | 591 'you are running Python %s.\nUse "gsutil config -a" to create a ' |
| 592 'config with Developer Key authentication credentials.' % sys.version) | 592 'config with Developer Key authentication credentials.' % sys.version) |
| 593 | 593 |
| 594 if not scopes: | 594 if not scopes: |
| 595 scopes.append(SCOPE_FULL_CONTROL) | 595 scopes.append(SCOPE_FULL_CONTROL) |
| 596 | 596 |
| 597 default_config_path_bak = None |
| 597 if output_file_name is None: | 598 if output_file_name is None: |
| 598 # Check to see if a default config file name is requested via | 599 # Check to see if a default config file name is requested via |
| 599 # environment variable. If so, use it, otherwise use the hard-coded | 600 # environment variable. If so, use it, otherwise use the hard-coded |
| 600 # default file. Then use the default config file name, if it doesn't | 601 # default file. Then use the default config file name, if it doesn't |
| 601 # exist or can be moved out of the way without clobbering an existing | 602 # exist or can be moved out of the way without clobbering an existing |
| 602 # backup file. | 603 # backup file. |
| 603 boto_config_from_env = os.environ.get('BOTO_CONFIG', None) | 604 boto_config_from_env = os.environ.get('BOTO_CONFIG', None) |
| 604 if boto_config_from_env: | 605 if boto_config_from_env: |
| 605 default_config_path = boto_config_from_env | 606 default_config_path = boto_config_from_env |
| 606 else: | 607 else: |
| 607 default_config_path = os.path.expanduser(os.path.join('~', '.boto')) | 608 default_config_path = os.path.expanduser(os.path.join('~', '.boto')) |
| 608 if not os.path.exists(default_config_path): | 609 if not os.path.exists(default_config_path): |
| 609 output_file_name = default_config_path | 610 output_file_name = default_config_path |
| 610 default_config_path_bak = None | |
| 611 else: | 611 else: |
| 612 default_config_path_bak = default_config_path + '.bak' | 612 default_config_path_bak = default_config_path + '.bak' |
| 613 if os.path.exists(default_config_path_bak): | 613 if os.path.exists(default_config_path_bak): |
| 614 raise CommandException('Cannot back up existing config ' | 614 raise CommandException('Cannot back up existing config ' |
| 615 'file "%s": backup file exists ("%s").' | 615 'file "%s": backup file exists ("%s").' |
| 616 % (default_config_path, default_config_path_bak)) | 616 % (default_config_path, default_config_path_bak)) |
| 617 else: | 617 else: |
| 618 try: | 618 try: |
| 619 sys.stderr.write( | 619 sys.stderr.write( |
| 620 'Backing up existing config file "%s" to "%s"...\n' | 620 'Backing up existing config file "%s" to "%s"...\n' |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 | 653 |
| 654 if output_file_name != '-': | 654 if output_file_name != '-': |
| 655 output_file.close() | 655 output_file.close() |
| 656 sys.stderr.write( | 656 sys.stderr.write( |
| 657 '\nBoto config file "%s" created.\n' % output_file_name) | 657 '\nBoto config file "%s" created.\n' % output_file_name) |
| 658 | 658 |
| 659 return 0 | 659 return 0 |
| 660 | 660 |
| 661 def cleanup_handler(signalnum, handler): | 661 def cleanup_handler(signalnum, handler): |
| 662 raise AbortException('User interrupted config command') | 662 raise AbortException('User interrupted config command') |
| OLD | NEW |