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

Side by Side Diff: client/run_isolated.py

Issue 2928153002: Return named output files if they're symlinks (Closed)
Patch Set: Fixed import order 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') | no next file with comments »
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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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:]))
OLDNEW
« no previous file with comments | « no previous file | client/tests/run_isolated_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698