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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 git_exe = 'git.bat' if sys.platform.startswith('win') else 'git' | 143 git_exe = 'git.bat' if sys.platform.startswith('win') else 'git' |
144 gsutil_exe = os.path.join( | 144 gsutil_exe = os.path.join( |
145 os.path.dirname(os.path.abspath(__file__)), 'gsutil.py') | 145 os.path.dirname(os.path.abspath(__file__)), 'gsutil.py') |
146 cachepath_lock = threading.Lock() | 146 cachepath_lock = threading.Lock() |
147 | 147 |
148 def __init__(self, url, refs=None, print_func=None): | 148 def __init__(self, url, refs=None, print_func=None): |
149 self.url = url | 149 self.url = url |
150 self.refs = refs or [] | 150 self.refs = refs or [] |
151 self.basedir = self.UrlToCacheDir(url) | 151 self.basedir = self.UrlToCacheDir(url) |
152 self.mirror_path = os.path.join(self.GetCachePath(), self.basedir) | 152 self.mirror_path = os.path.join(self.GetCachePath(), self.basedir) |
153 self.print = print_func or print | 153 if print_func: |
| 154 self.print = self.print_without_file |
| 155 self.print_func = print_func |
| 156 else: |
| 157 self.print = print |
| 158 |
| 159 def print_without_file(self, message, **kwargs): |
| 160 self.print_func(message) |
154 | 161 |
155 @property | 162 @property |
156 def bootstrap_bucket(self): | 163 def bootstrap_bucket(self): |
157 if 'chrome-internal' in self.url: | 164 if 'chrome-internal' in self.url: |
158 return 'chrome-git-cache' | 165 return 'chrome-git-cache' |
159 else: | 166 else: |
160 return 'chromium-git-cache' | 167 return 'chromium-git-cache' |
161 | 168 |
162 @classmethod | 169 @classmethod |
163 def FromPath(cls, path): | 170 def FromPath(cls, path): |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 return options, args | 691 return options, args |
685 | 692 |
686 | 693 |
687 def main(argv): | 694 def main(argv): |
688 dispatcher = subcommand.CommandDispatcher(__name__) | 695 dispatcher = subcommand.CommandDispatcher(__name__) |
689 return dispatcher.execute(OptionParser(), argv) | 696 return dispatcher.execute(OptionParser(), argv) |
690 | 697 |
691 | 698 |
692 if __name__ == '__main__': | 699 if __name__ == '__main__': |
693 sys.exit(main(sys.argv[1:])) | 700 sys.exit(main(sys.argv[1:])) |
OLD | NEW |