Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2016 The LUCI Authors. All rights reserved. | 1 # Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 """Fetches CIPD client and installs packages.""" | 5 """Fetches CIPD client and installs packages.""" |
| 6 | 6 |
| 7 __version__ = '0.1' | 7 __version__ = '0.1' |
| 8 | 8 |
| 9 import contextlib | 9 import contextlib |
| 10 import hashlib | 10 import hashlib |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 388 logging.info('Fetching CIPD client %s:%s', package_name, instance_id) | 388 logging.info('Fetching CIPD client %s:%s', package_name, instance_id) |
| 389 fetch_url = get_client_fetch_url( | 389 fetch_url = get_client_fetch_url( |
| 390 service_url, package_name, instance_id, timeout=timeoutfn()) | 390 service_url, package_name, instance_id, timeout=timeoutfn()) |
| 391 _fetch_cipd_client(instance_cache, instance_id, fetch_url, timeoutfn) | 391 _fetch_cipd_client(instance_cache, instance_id, fetch_url, timeoutfn) |
| 392 | 392 |
| 393 # A single host can run multiple swarming bots, but ATM they do not share | 393 # A single host can run multiple swarming bots, but ATM they do not share |
| 394 # same root bot directory. Thus, it is safe to use the same name for the | 394 # same root bot directory. Thus, it is safe to use the same name for the |
| 395 # binary. | 395 # binary. |
| 396 binary_path = unicode(os.path.join(cache_dir, 'cipd' + EXECUTABLE_SUFFIX)) | 396 binary_path = unicode(os.path.join(cache_dir, 'cipd' + EXECUTABLE_SUFFIX)) |
| 397 if fs.isfile(binary_path): | 397 if fs.isfile(binary_path): |
| 398 # Ensure file is writable to delete the hardlink. This is important on | |
| 399 # Windows. Note that mode is stored on file node, not the hardlink, so | |
| 400 # keep it executable. | |
| 401 fs.chmod(0711, binary_path) | |
|
M-A Ruel
2016/06/14 18:17:46
file_path.try_remove() does it automatically.
nodir
2016/06/14 22:16:05
Done.
| |
| 398 fs.unlink(binary_path) | 402 fs.unlink(binary_path) |
| 399 instance_cache.hardlink(instance_id, binary_path, 0511) # -r-x--x--x | 403 instance_cache.hardlink(instance_id, binary_path, 0511) # -r-x--x--x |
| 400 | 404 |
| 401 yield CipdClient(binary_path) | 405 yield CipdClient(binary_path) |
| OLD | NEW |