Chromium Code Reviews| 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 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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' |
| 621 % (default_config_path, default_config_path_bak)) | 621 % (default_config_path, default_config_path_bak)) |
| 622 os.rename(default_config_path, default_config_path_bak) | 622 os.rename(default_config_path, default_config_path_bak) |
| 623 except e: | 623 except e: |
| 624 raise CommandException('Failed to back up existing config ' | 624 raise CommandException('Failed to back up existing config ' |
| 625 'file ("%s" -> "%s"): %s.' | 625 'file ("%s" -> "%s"): %s.' |
| 626 % (default_config_path, default_config_path_bak, e)) | 626 % (default_config_path, default_config_path_bak, e)) |
| 627 output_file_name = default_config_path | 627 output_file_name = default_config_path |
| 628 else: | |
| 629 default_config_path_bak = None | |
|
Ryan Tseng
2014/06/23 21:29:22
Move this before 597 before the if (to make it mor
| |
| 628 | 630 |
| 629 if output_file_name == '-': | 631 if output_file_name == '-': |
| 630 output_file = sys.stdout | 632 output_file = sys.stdout |
| 631 else: | 633 else: |
| 632 output_file = self._OpenConfigFile(output_file_name) | 634 output_file = self._OpenConfigFile(output_file_name) |
| 633 | 635 |
| 634 # Catch ^C so we can restore the backup. | 636 # Catch ^C so we can restore the backup. |
| 635 signal.signal(signal.SIGINT, cleanup_handler) | 637 signal.signal(signal.SIGINT, cleanup_handler) |
| 636 try: | 638 try: |
| 637 self._WriteBotoConfigFile(output_file, use_oauth2=use_oauth2, | 639 self._WriteBotoConfigFile(output_file, use_oauth2=use_oauth2, |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 653 | 655 |
| 654 if output_file_name != '-': | 656 if output_file_name != '-': |
| 655 output_file.close() | 657 output_file.close() |
| 656 sys.stderr.write( | 658 sys.stderr.write( |
| 657 '\nBoto config file "%s" created.\n' % output_file_name) | 659 '\nBoto config file "%s" created.\n' % output_file_name) |
| 658 | 660 |
| 659 return 0 | 661 return 0 |
| 660 | 662 |
| 661 def cleanup_handler(signalnum, handler): | 663 def cleanup_handler(signalnum, handler): |
| 662 raise AbortException('User interrupted config command') | 664 raise AbortException('User interrupted config command') |
| OLD | NEW |