Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """Download files from Google Storage based on SHA1 sums.""" | 6 """Download files from Google Storage based on SHA1 sums.""" |
| 7 | 7 |
| 8 | 8 |
| 9 import hashlib | 9 import hashlib |
| 10 import optparse | 10 import optparse |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 39 if not os.path.exists(path): | 39 if not os.path.exists(path): |
| 40 raise FileNotFoundError('GSUtil not found in %s' % path) | 40 raise FileNotFoundError('GSUtil not found in %s' % path) |
| 41 self.path = path | 41 self.path = path |
| 42 self.timeout = timeout | 42 self.timeout = timeout |
| 43 self.boto_path = boto_path | 43 self.boto_path = boto_path |
| 44 | 44 |
| 45 def call(self, *args): | 45 def call(self, *args): |
| 46 env = os.environ.copy() | 46 env = os.environ.copy() |
| 47 if self.boto_path: | 47 if self.boto_path: |
| 48 env['AWS_CREDENTIAL_FILE'] = self.boto_path | 48 env['AWS_CREDENTIAL_FILE'] = self.boto_path |
| 49 else: | |
| 50 custompath = env.get('AWS_CREDENTIAL_FILE', '~/.boto') + '.depot_tools' | |
| 51 custompath = os.path.expanduser(custompath) | |
| 52 if os.path.exists(custompath): | |
| 53 env['AWS_CREDENTIAL_FILE'] = custompath | |
| 54 | |
| 49 return subprocess2.call((sys.executable, self.path) + args, | 55 return subprocess2.call((sys.executable, self.path) + args, |
| 50 env=env, | 56 env=env, |
| 51 timeout=self.timeout) | 57 timeout=self.timeout) |
| 52 | 58 |
| 53 def check_call(self, *args): | 59 def check_call(self, *args): |
| 54 env = os.environ.copy() | 60 env = os.environ.copy() |
| 55 if self.boto_path: | 61 if self.boto_path: |
| 56 env['AWS_CREDENTIAL_FILE'] = self.boto_path | 62 env['AWS_CREDENTIAL_FILE'] = self.boto_path |
|
Ryan Tseng
2013/06/26 19:26:31
Also need to do it here.
| |
| 57 ((out, err), code) = subprocess2.communicate( | 63 ((out, err), code) = subprocess2.communicate( |
| 58 (sys.executable, self.path) + args, | 64 (sys.executable, self.path) + args, |
| 59 stdout=subprocess2.PIPE, | 65 stdout=subprocess2.PIPE, |
| 60 stderr=subprocess2.PIPE, | 66 stderr=subprocess2.PIPE, |
| 61 env=env, | 67 env=env, |
| 62 timeout=self.timeout) | 68 timeout=self.timeout) |
| 63 | 69 |
| 64 # Parse output. | 70 # Parse output. |
| 65 status_code_match = re.search('status=([0-9]+)', err) | 71 status_code_match = re.search('status=([0-9]+)', err) |
| 66 if status_code_match: | 72 if status_code_match: |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 return code | 335 return code |
| 330 | 336 |
| 331 return download_from_google_storage( | 337 return download_from_google_storage( |
| 332 input_filename, base_url, gsutil, options.num_threads, options.directory, | 338 input_filename, base_url, gsutil, options.num_threads, options.directory, |
| 333 options.recursive, options.force, options.output, options.ignore_errors, | 339 options.recursive, options.force, options.output, options.ignore_errors, |
| 334 options.sha1_file) | 340 options.sha1_file) |
| 335 | 341 |
| 336 | 342 |
| 337 if __name__ == '__main__': | 343 if __name__ == '__main__': |
| 338 sys.exit(main(sys.argv)) | 344 sys.exit(main(sys.argv)) |
| OLD | NEW |