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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 def link_outputs_to_outdir(run_dir, out_dir, outputs): | 360 def link_outputs_to_outdir(run_dir, out_dir, outputs): |
361 """Links any named outputs to out_dir so they can be uploaded. | 361 """Links any named outputs to out_dir so they can be uploaded. |
362 | 362 |
363 Raises an error if the file already exists in that directory. | 363 Raises an error if the file already exists in that directory. |
364 """ | 364 """ |
365 if not outputs: | 365 if not outputs: |
366 return | 366 return |
367 isolateserver.create_directories(out_dir, outputs) | 367 isolateserver.create_directories(out_dir, outputs) |
368 for o in outputs: | 368 for o in outputs: |
369 try: | 369 try: |
370 file_path.link_file( | 370 infile = os.path.join(run_dir, o) |
371 os.path.join(out_dir, o), | 371 outfile = os.path.join(out_dir, o) |
372 os.path.join(run_dir, o), | 372 if fs.islink(infile): |
373 file_path.HARDLINK_WITH_FALLBACK) | 373 # TODO(aludwin): handle directories |
| 374 fs.copy2(infile, outfile) |
| 375 else: |
| 376 file_path.link_file(outfile, infile, file_path.HARDLINK_WITH_FALLBACK) |
374 except OSError as e: | 377 except OSError as e: |
375 logging.info("Couldn't collect output file %s: %s", o, e) | 378 logging.info("Couldn't collect output file %s: %s", o, e) |
376 | 379 |
377 | 380 |
378 def delete_and_upload(storage, out_dir, leak_temp_dir): | 381 def delete_and_upload(storage, out_dir, leak_temp_dir): |
379 """Deletes the temporary run directory and uploads results back. | 382 """Deletes the temporary run directory and uploads results back. |
380 | 383 |
381 Returns: | 384 Returns: |
382 tuple(outputs_ref, success, stats) | 385 tuple(outputs_ref, success, stats) |
383 - outputs_ref: a dict referring to the results archived back to the isolated | 386 - outputs_ref: a dict referring to the results archived back to the isolated |
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 return 1 | 1098 return 1 |
1096 | 1099 |
1097 | 1100 |
1098 if __name__ == '__main__': | 1101 if __name__ == '__main__': |
1099 subprocess42.inhibit_os_error_reporting() | 1102 subprocess42.inhibit_os_error_reporting() |
1100 # Ensure that we are always running with the correct encoding. | 1103 # Ensure that we are always running with the correct encoding. |
1101 fix_encoding.fix_encoding() | 1104 fix_encoding.fix_encoding() |
1102 file_path.enable_symlink() | 1105 file_path.enable_symlink() |
1103 | 1106 |
1104 sys.exit(main(sys.argv[1:])) | 1107 sys.exit(main(sys.argv[1:])) |
OLD | NEW |