OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 """A git command for managing a local cache of git repositories.""" | 6 """A git command for managing a local cache of git repositories.""" |
7 | 7 |
8 from __future__ import print_function | 8 from __future__ import print_function |
9 import errno | 9 import errno |
10 import logging | 10 import logging |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 151 |
152 for path_folder in path_folders: | 152 for path_folder in path_folders: |
153 target = os.path.join(path_folder, executable) | 153 target = os.path.join(path_folder, executable) |
154 # Just incase we have some ~/blah paths. | 154 # Just incase we have some ~/blah paths. |
155 target = os.path.abspath(os.path.expanduser(target)) | 155 target = os.path.abspath(os.path.expanduser(target)) |
156 if os.path.isfile(target) and os.access(target, os.X_OK): | 156 if os.path.isfile(target) and os.access(target, os.X_OK): |
157 return target | 157 return target |
158 if sys.platform.startswith('win'): | 158 if sys.platform.startswith('win'): |
159 for suffix in ('.bat', '.cmd', '.exe'): | 159 for suffix in ('.bat', '.cmd', '.exe'): |
160 alt_target = target + suffix | 160 alt_target = target + suffix |
161 if os.path.isfile(alt_target) and os.access(target, os.X_OK): | 161 if os.path.isfile(alt_target) and os.access(alt_target, os.X_OK): |
162 return alt_target | 162 return alt_target |
163 return None | 163 return None |
164 | 164 |
165 @classmethod | 165 @classmethod |
166 def SetCachePath(cls, cachepath): | 166 def SetCachePath(cls, cachepath): |
167 setattr(cls, 'cachepath', cachepath) | 167 setattr(cls, 'cachepath', cachepath) |
168 | 168 |
169 @classmethod | 169 @classmethod |
170 def GetCachePath(cls): | 170 def GetCachePath(cls): |
171 if not hasattr(cls, 'cachepath'): | 171 if not hasattr(cls, 'cachepath'): |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 return options, args | 490 return options, args |
491 | 491 |
492 | 492 |
493 def main(argv): | 493 def main(argv): |
494 dispatcher = subcommand.CommandDispatcher(__name__) | 494 dispatcher = subcommand.CommandDispatcher(__name__) |
495 return dispatcher.execute(OptionParser(), argv) | 495 return dispatcher.execute(OptionParser(), argv) |
496 | 496 |
497 | 497 |
498 if __name__ == '__main__': | 498 if __name__ == '__main__': |
499 sys.exit(main(sys.argv[1:])) | 499 sys.exit(main(sys.argv[1:])) |
OLD | NEW |