Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium OS 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 """Wrapper for chromite tools. | 6 """Wrapper for chromite tools. |
| 7 | 7 |
| 8 The script is intend to be symlinked to any number of chromite tools, attempts | 8 The script is intend to be symlinked to any number of chromite tools, attempts |
| 9 to find the path for chromite, and hands off to the right tool via exec if | 9 to find the path for chromite, and hands off to the right tool via exec if |
| 10 possible. | 10 possible. |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 import os | 23 import os |
| 24 import sys | 24 import sys |
| 25 | 25 |
| 26 # Due to historical reasons, and the fact depot_tools ToT is used by older | 26 # Due to historical reasons, and the fact depot_tools ToT is used by older |
| 27 # factory branches (lacking chromite script cleanups), note we have to | 27 # factory branches (lacking chromite script cleanups), note we have to |
| 28 # fallback to some odd import locations. This is the only reason for the | 28 # fallback to some odd import locations. This is the only reason for the |
| 29 # fallback code- any/all new scripts symlinked to this script *must* exist | 29 # fallback code- any/all new scripts symlinked to this script *must* exist |
| 30 # in chromite/bin/ . | 30 # in chromite/bin/ . |
| 31 | 31 |
| 32 def _FindChromite(path): | 32 def _FindChromite(path): |
| 33 """Find the chromite dir in a repo or gclient checkout.""" | 33 """Find the chromite dir in a repo or gclient checkout.""" |
|
cmp_google
2013/05/03 21:45:51
Update the heredoc so it's correct.
| |
| 34 path = os.path.abspath(path) | 34 path = os.path.abspath(path) |
| 35 # Depending on the checkout type (whether repo chromeos or gclient chrome) | 35 # Depending on the checkout type (whether repo chromeos or gclient chrome) |
| 36 # Chromite lives in a different location. | 36 # Chromite lives in a different location. |
| 37 roots = ( | 37 roots = ( |
| 38 ('.repo', 'chromite/.git'), | 38 ('.repo', 'chromite/.git'), |
| 39 ('.gclient', 'src/third_party/chromite/.git'), | 39 ('.gclient', 'src/third_party/chromite/.git'), |
| 40 ('src/.gitmodules', 'src/third_party/chromite/.git'), | |
| 40 ) | 41 ) |
| 41 | 42 |
| 42 while path != '/': | 43 while path != '/': |
| 43 for root, chromite_git_dir in roots: | 44 for root, chromite_git_dir in roots: |
| 44 if all(os.path.exists(os.path.join(path, x)) | 45 if all(os.path.exists(os.path.join(path, x)) |
| 45 for x in [root, chromite_git_dir]): | 46 for x in [root, chromite_git_dir]): |
| 46 return os.path.dirname(os.path.join(path, chromite_git_dir)) | 47 return os.path.dirname(os.path.join(path, chromite_git_dir)) |
| 47 path = os.path.dirname(path) | 48 path = os.path.dirname(path) |
| 48 return None | 49 return None |
| 49 | 50 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 sys.path.insert(0, os.path.dirname(chromite_dir)) | 87 sys.path.insert(0, os.path.dirname(chromite_dir)) |
| 87 | 88 |
| 88 try: | 89 try: |
| 89 module = __import__(target, fromlist=['main']) | 90 module = __import__(target, fromlist=['main']) |
| 90 except ImportError: | 91 except ImportError: |
| 91 return _MissingErrorOut(target) | 92 return _MissingErrorOut(target) |
| 92 return module.main() | 93 return module.main() |
| 93 | 94 |
| 94 if __name__ == '__main__': | 95 if __name__ == '__main__': |
| 95 sys.exit(main()) | 96 sys.exit(main()) |
| OLD | NEW |