Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: client/run_isolated.py

Issue 2928153002: Return named output files if they're symlinks (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | client/tests/run_isolated_test.py » ('j') | client/tests/run_isolated_test.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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:]))
OLDNEW
« no previous file with comments | « no previous file | client/tests/run_isolated_test.py » ('j') | client/tests/run_isolated_test.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698