| 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 by the Apache v2.0 license that can be | 3 # Use of this source code is governed by the Apache v2.0 license that can be |
| 4 # found in the LICENSE file. | 4 # 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 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 '%s in args requires --isolate-server' % ISOLATED_OUTDIR_PARAMETER) | 596 '%s in args requires --isolate-server' % ISOLATED_OUTDIR_PARAMETER) |
| 597 | 597 |
| 598 if options.root_dir: | 598 if options.root_dir: |
| 599 options.root_dir = unicode(os.path.abspath(options.root_dir)) | 599 options.root_dir = unicode(os.path.abspath(options.root_dir)) |
| 600 if options.json: | 600 if options.json: |
| 601 options.json = unicode(os.path.abspath(options.json)) | 601 options.json = unicode(os.path.abspath(options.json)) |
| 602 | 602 |
| 603 command = [] if options.isolated else args | 603 command = [] if options.isolated else args |
| 604 if options.isolate_server: | 604 if options.isolate_server: |
| 605 storage = isolateserver.get_storage( | 605 storage = isolateserver.get_storage( |
| 606 options.isolate_server, options.namespace) | 606 options.isolate_server, options.namespace) |
| 607 # Hashing schemes used by |storage| and |cache| MUST match. | 607 # Hashing schemes used by |storage| and |cache| MUST match. |
| 608 assert storage.hash_algo == cache.hash_algo | 608 with storage: |
| 609 return run_tha_test( | 609 assert storage.hash_algo == cache.hash_algo |
| 610 command, options.isolated, storage, cache, options.leak_temp_dir, | 610 return run_tha_test( |
| 611 options.json, options.root_dir, options.hard_timeout, | 611 command, options.isolated, storage, cache, options.leak_temp_dir, |
| 612 options.grace_period, args) | 612 options.json, options.root_dir, options.hard_timeout, |
| 613 options.grace_period, args) |
| 613 else: | 614 else: |
| 614 return run_tha_test( | 615 return run_tha_test( |
| 615 command, options.isolated, None, cache, options.leak_temp_dir, | 616 command, options.isolated, None, cache, options.leak_temp_dir, |
| 616 options.json, options.root_dir, options.hard_timeout, | 617 options.json, options.root_dir, options.hard_timeout, |
| 617 options.grace_period, args) | 618 options.grace_period, args) |
| 618 | 619 |
| 619 | 620 |
| 620 if __name__ == '__main__': | 621 if __name__ == '__main__': |
| 621 # Ensure that we are always running with the correct encoding. | 622 # Ensure that we are always running with the correct encoding. |
| 622 fix_encoding.fix_encoding() | 623 fix_encoding.fix_encoding() |
| 623 sys.exit(main(sys.argv[1:])) | 624 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |