| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
| 3 # | 3 # |
| 4 # Use of this source code is governed by a BSD-style license | 4 # Use of this source code is governed by a BSD-style license |
| 5 # that can be found in the LICENSE file in the root of the source | 5 # that can be found in the LICENSE file in the root of the source |
| 6 # tree. An additional intellectual property rights grant can be found | 6 # tree. An additional intellectual property rights grant can be found |
| 7 # in the file PATENTS. All contributing project authors may | 7 # in the file PATENTS. All contributing project authors may |
| 8 # be found in the AUTHORS file in the root of the source tree. | 8 # be found in the AUTHORS file in the root of the source tree. |
| 9 | 9 |
| 10 """Script to cleanup symlinks created from setup_links.py. | 10 """Script to cleanup symlinks created from setup_links.py. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 if not self._dry_run: | 46 if not self._dry_run: |
| 47 if os.path.exists(link_path): | 47 if os.path.exists(link_path): |
| 48 if sys.platform.startswith('win') and os.path.isdir(link_path): | 48 if sys.platform.startswith('win') and os.path.isdir(link_path): |
| 49 subprocess.check_call(['rmdir', '/q', '/s', link_path], | 49 subprocess.check_call(['rmdir', '/q', '/s', link_path], |
| 50 shell=True) | 50 shell=True) |
| 51 else: | 51 else: |
| 52 os.remove(link_path) | 52 os.remove(link_path) |
| 53 del self._links_db[source] | 53 del self._links_db[source] |
| 54 | 54 |
| 55 | 55 |
| 56 def _initialize_database(filename): | 56 def _InitializeDatabase(filename): |
| 57 links_database = shelve.open(filename) | 57 links_database = shelve.open(filename) |
| 58 # Wipe the database if this version of the script ends up looking at a | 58 # Wipe the database if this version of the script ends up looking at a |
| 59 # newer (future) version of the links db, just to be sure. | 59 # newer (future) version of the links db, just to be sure. |
| 60 version = links_database.get('SCHEMA_VERSION') | 60 version = links_database.get('SCHEMA_VERSION') |
| 61 if version and version != SCHEMA_VERSION: | 61 if version and version != SCHEMA_VERSION: |
| 62 logging.info('Found database with schema version %s while this script only ' | 62 logging.info('Found database with schema version %s while this script only ' |
| 63 'supports %s. Wiping previous database contents.', version, | 63 'supports %s. Wiping previous database contents.', version, |
| 64 SCHEMA_VERSION) | 64 SCHEMA_VERSION) |
| 65 links_database.clear() | 65 links_database.clear() |
| 66 links_database['SCHEMA_VERSION'] = SCHEMA_VERSION | 66 links_database['SCHEMA_VERSION'] = SCHEMA_VERSION |
| (...skipping 15 matching lines...) Expand all Loading... |
| 82 options.verbose = logging.DEBUG | 82 options.verbose = logging.DEBUG |
| 83 logging.basicConfig(format='%(message)s', level=options.verbose) | 83 logging.basicConfig(format='%(message)s', level=options.verbose) |
| 84 | 84 |
| 85 # Work from the root directory of the checkout. | 85 # Work from the root directory of the checkout. |
| 86 script_dir = os.path.dirname(os.path.abspath(__file__)) | 86 script_dir = os.path.dirname(os.path.abspath(__file__)) |
| 87 os.chdir(script_dir) | 87 os.chdir(script_dir) |
| 88 | 88 |
| 89 # The database file gets .db appended on some platforms. | 89 # The database file gets .db appended on some platforms. |
| 90 db_filenames = [LINKS_DB, LINKS_DB + '.db'] | 90 db_filenames = [LINKS_DB, LINKS_DB + '.db'] |
| 91 if any(os.path.isfile(f) for f in db_filenames): | 91 if any(os.path.isfile(f) for f in db_filenames): |
| 92 links_database = _initialize_database(LINKS_DB) | 92 links_database = _InitializeDatabase(LINKS_DB) |
| 93 try: | 93 try: |
| 94 symlink_creator = WebRTCLinkSetup(links_database, options.dry_run) | 94 symlink_creator = WebRTCLinkSetup(links_database, options.dry_run) |
| 95 symlink_creator.CleanupLinks() | 95 symlink_creator.CleanupLinks() |
| 96 finally: | 96 finally: |
| 97 for f in db_filenames: | 97 for f in db_filenames: |
| 98 if os.path.isfile(f): | 98 if os.path.isfile(f): |
| 99 os.remove(f) | 99 os.remove(f) |
| 100 return 0 | 100 return 0 |
| 101 | 101 |
| 102 | 102 |
| 103 if __name__ == '__main__': | 103 if __name__ == '__main__': |
| 104 sys.exit(main()) | 104 sys.exit(main()) |
| OLD | NEW |