Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | |
| 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 # 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 |
| 3 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 4 """Small utility function to find depot_tools and add it to the python path. | 5 """Small utility function to find depot_tools and add it to the python path. |
| 5 | 6 |
| 6 Will throw an ImportError exception if depot_tools can't be found since it | 7 Will throw an ImportError exception if depot_tools can't be found since it |
| 7 imports breakpad. | 8 imports breakpad. |
| 9 | |
| 10 This can also be used as a standlone script to print out the depot_tools | |
|
Dirk Pranke
2015/10/23 22:07:53
nit: "standalone"
Roland McGrath
2015/10/23 22:55:45
Done.
| |
| 11 directory location. | |
| 8 """ | 12 """ |
| 9 | 13 |
| 10 import os | 14 import os |
| 11 import sys | 15 import sys |
| 12 | 16 |
| 13 | 17 |
| 14 def IsRealDepotTools(path): | 18 def IsRealDepotTools(path): |
| 15 return os.path.isfile(os.path.join(path, 'gclient.py')) | 19 return os.path.isfile(os.path.join(path, 'gclient.py')) |
| 16 | 20 |
| 17 | 21 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 32 while root_dir and root_dir != previous_dir: | 36 while root_dir and root_dir != previous_dir: |
| 33 i = os.path.join(root_dir, 'depot_tools') | 37 i = os.path.join(root_dir, 'depot_tools') |
| 34 if IsRealDepotTools(i): | 38 if IsRealDepotTools(i): |
| 35 sys.path.append(i) | 39 sys.path.append(i) |
| 36 return i | 40 return i |
| 37 previous_dir = root_dir | 41 previous_dir = root_dir |
| 38 root_dir = os.path.dirname(root_dir) | 42 root_dir = os.path.dirname(root_dir) |
| 39 print >> sys.stderr, 'Failed to find depot_tools' | 43 print >> sys.stderr, 'Failed to find depot_tools' |
| 40 return None | 44 return None |
| 41 | 45 |
| 42 add_depot_tools_to_path() | 46 DEPOT_TOOLS_PATH = add_depot_tools_to_path() |
| 43 | 47 |
| 44 # pylint: disable=W0611 | 48 # pylint: disable=W0611 |
| 45 import breakpad | 49 import breakpad |
| 50 | |
| 51 | |
| 52 def main(): | |
| 53 if DEPOT_TOOLS_PATH is None: | |
| 54 return 1 | |
| 55 print DEPOT_TOOLS_PATH | |
| 56 return 0 | |
| 57 | |
| 58 | |
| 59 if __name__ == '__main__': | |
| 60 sys.exit(main()) | |
| OLD | NEW |