Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2012 The LUCI Authors. All rights reserved. | 2 # Copyright 2012 The LUCI Authors. All rights reserved. |
| 3 # Use of this source code is governed under the Apache License, Version 2.0 | 3 # Use of this source code is governed under the Apache License, Version 2.0 |
| 4 # that can be found in the LICENSE file. | 4 # that can be found in the LICENSE file. |
| 5 | 5 |
| 6 """Runs a command with optional isolated input/output. | 6 """Runs a command with optional isolated input/output. |
| 7 | 7 |
| 8 Despite name "run_isolated", can run a generic non-isolated command specified as | 8 Despite name "run_isolated", can run a generic non-isolated command specified as |
| 9 args. | 9 args. |
| 10 | 10 |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 325 def link_outputs_to_outdir(run_dir, out_dir, outputs): | 325 def link_outputs_to_outdir(run_dir, out_dir, outputs): |
| 326 """Links any named outputs to out_dir so they can be uploaded. | 326 """Links any named outputs to out_dir so they can be uploaded. |
| 327 | 327 |
| 328 Raises an error if the file already exists in that directory. | 328 Raises an error if the file already exists in that directory. |
| 329 """ | 329 """ |
| 330 if not outputs: | 330 if not outputs: |
| 331 return | 331 return |
| 332 isolateserver.create_directories(out_dir, outputs) | 332 isolateserver.create_directories(out_dir, outputs) |
| 333 for o in outputs: | 333 for o in outputs: |
| 334 try: | 334 try: |
| 335 file_path.link_file( | 335 infile = os.path.join(run_dir, o) |
| 336 os.path.join(out_dir, o), | 336 outfile = os.path.join(out_dir, o) |
| 337 os.path.join(run_dir, o), | 337 if os.path.islink(infile): |
|
M-A Ruel
2017/06/09 17:00:40
use fs.islink() otherwise this throws on Windows.
aludwin
2017/06/09 19:37:32
Done.
| |
| 338 file_path.HARDLINK_WITH_FALLBACK) | 338 # TODO(aludwin): handle directories |
| 339 file_path.readable_copy(outfile, os.path.realpath(infile)) | |
|
M-A Ruel
2017/06/09 17:00:40
use fs.copy2()
I don't think realpath() is necessa
aludwin
2017/06/09 19:37:32
Done.
| |
| 340 else: | |
| 341 file_path.link_file(outfile, infile, file_path.HARDLINK_WITH_FALLBACK) | |
| 339 except OSError as e: | 342 except OSError as e: |
| 340 logging.info("Couldn't collect output file %s: %s", o, e) | 343 logging.info("Couldn't collect output file %s: %s", o, e) |
| 341 | 344 |
| 342 | 345 |
| 343 def delete_and_upload(storage, out_dir, leak_temp_dir): | 346 def delete_and_upload(storage, out_dir, leak_temp_dir): |
| 344 """Deletes the temporary run directory and uploads results back. | 347 """Deletes the temporary run directory and uploads results back. |
| 345 | 348 |
| 346 Returns: | 349 Returns: |
| 347 tuple(outputs_ref, success, stats) | 350 tuple(outputs_ref, success, stats) |
| 348 - outputs_ref: a dict referring to the results archived back to the isolated | 351 - outputs_ref: a dict referring to the results archived back to the isolated |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1068 return 1 | 1071 return 1 |
| 1069 | 1072 |
| 1070 | 1073 |
| 1071 if __name__ == '__main__': | 1074 if __name__ == '__main__': |
| 1072 subprocess42.inhibit_os_error_reporting() | 1075 subprocess42.inhibit_os_error_reporting() |
| 1073 # Ensure that we are always running with the correct encoding. | 1076 # Ensure that we are always running with the correct encoding. |
| 1074 fix_encoding.fix_encoding() | 1077 fix_encoding.fix_encoding() |
| 1075 file_path.enable_symlink() | 1078 file_path.enable_symlink() |
| 1076 | 1079 |
| 1077 sys.exit(main(sys.argv[1:])) | 1080 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |