| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Script that deletes all symlinks created by setup_links.py in a checkout.""" | 6 """Script that deletes all symlinks created by setup_links.py in a checkout.""" |
| 7 | 7 |
| 8 import os | 8 import os |
| 9 import subprocess | 9 import subprocess |
| 10 import sys | 10 import sys |
| 11 | 11 |
| 12 | 12 |
| 13 def main(args): | 13 def main(args): |
| 14 if len(args) != 1: | 14 if len(args) != 1: |
| 15 print >> sys.stderr, ('Please specify a single directory as an argument, ' | 15 print >> sys.stderr, ('Please specify a single directory as an argument, ' |
| 16 'which points to the checkout root (dir above src/).' | 16 'which points to the checkout root (dir above src/).') |
| 17 return 1 | 17 return 1 |
| 18 | 18 |
| 19 checkout_root = args[0] | 19 checkout_root = args[0] |
| 20 if not os.path.isdir(checkout_root): | 20 if not os.path.isdir(checkout_root): |
| 21 print 'Cannot find any directory at %s. Skipping cleaning.' % checkout_root | 21 print 'Cannot find any directory at %s. Skipping cleaning.' % checkout_root |
| 22 return 0 | 22 return 0 |
| 23 | 23 |
| 24 setup_links_file = os.path.join(checkout_root, 'src', 'setup_links.py') | 24 setup_links_file = os.path.join(checkout_root, 'src', 'setup_links.py') |
| 25 if os.path.isfile(setup_links_file): | 25 if os.path.isfile(setup_links_file): |
| 26 print 'Cleaning up symlinks in %s' % checkout_root | 26 print 'Cleaning up symlinks in %s' % checkout_root |
| 27 subprocess.check_call([sys.executable, setup_links_file, '--clean-only'], | 27 subprocess.check_call([sys.executable, setup_links_file, '--clean-only'], |
| 28 cwd=checkout_root) | 28 cwd=checkout_root) |
| 29 return 0 | 29 return 0 |
| 30 | 30 |
| 31 | 31 |
| 32 if __name__ == '__main__': | 32 if __name__ == '__main__': |
| 33 sys.exit(main(sys.argv[1:])) | 33 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |