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, gclient, or submodule checkout.""" |
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 ('src/.gitmodules', 'src/third_party/chromite/.git'), |
41 ) | 41 ) |
42 | 42 |
43 while path != '/': | 43 while path != '/': |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 sys.path.insert(0, os.path.dirname(chromite_dir)) | 87 sys.path.insert(0, os.path.dirname(chromite_dir)) |
88 | 88 |
89 try: | 89 try: |
90 module = __import__(target, fromlist=['main']) | 90 module = __import__(target, fromlist=['main']) |
91 except ImportError: | 91 except ImportError: |
92 return _MissingErrorOut(target) | 92 return _MissingErrorOut(target) |
93 return module.main() | 93 return module.main() |
94 | 94 |
95 if __name__ == '__main__': | 95 if __name__ == '__main__': |
96 sys.exit(main()) | 96 sys.exit(main()) |
OLD | NEW |