OLD | NEW |
1 # Copyright 2013 The LUCI Authors. All rights reserved. | 1 # Copyright 2013 The LUCI Authors. All rights reserved. |
2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
4 | 4 |
5 """Runs a Swarming task. | 5 """Runs a Swarming task. |
6 | 6 |
7 Downloads all the necessary files to run the task, executes the command and | 7 Downloads all the necessary files to run the task, executes the command and |
8 streams results back to the Swarming server. | 8 streams results back to the Swarming server. |
9 | 9 |
10 The process exit code is 0 when the task was executed, even if the task itself | 10 The process exit code is 0 when the task was executed, even if the task itself |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 """Returns the path to itself to run run_isolated. | 78 """Returns the path to itself to run run_isolated. |
79 | 79 |
80 Mocked in test to point to the real run_isolated.py script. | 80 Mocked in test to point to the real run_isolated.py script. |
81 """ | 81 """ |
82 return [sys.executable, THIS_FILE, 'run_isolated'] | 82 return [sys.executable, THIS_FILE, 'run_isolated'] |
83 | 83 |
84 | 84 |
85 def get_isolated_args(is_grpc, work_dir, task_details, isolated_result, | 85 def get_isolated_args(is_grpc, work_dir, task_details, isolated_result, |
86 bot_file, run_isolated_flags): | 86 bot_file, run_isolated_flags): |
87 """Returns the command to call run_isolated. Mocked in tests.""" | 87 """Returns the command to call run_isolated. Mocked in tests.""" |
88 assert (bool(task_details.command) != | |
89 bool(task_details.isolated and task_details.isolated.get('input'))) | |
90 bot_dir = os.path.dirname(work_dir) | 88 bot_dir = os.path.dirname(work_dir) |
91 if os.path.isfile(isolated_result): | 89 if os.path.isfile(isolated_result): |
92 os.remove(isolated_result) | 90 os.remove(isolated_result) |
93 cmd = [] | 91 cmd = [] |
94 | 92 |
95 # Isolated options. | 93 # Isolated options. |
96 if task_details.isolated: | 94 if task_details.isolated: |
97 cmd.extend( | 95 cmd.extend( |
98 [ | 96 [ |
99 '-I', task_details.isolated['server'].encode('utf-8'), | 97 '-I', task_details.isolated['server'].encode('utf-8'), |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 options.start = now | 672 options.start = now |
675 | 673 |
676 try: | 674 try: |
677 load_and_run( | 675 load_and_run( |
678 options.in_file, options.swarming_server, options.is_grpc, | 676 options.in_file, options.swarming_server, options.is_grpc, |
679 options.cost_usd_hour, options.start, options.out_file, | 677 options.cost_usd_hour, options.start, options.out_file, |
680 args, options.bot_file, options.auth_params_file) | 678 args, options.bot_file, options.auth_params_file) |
681 return 0 | 679 return 0 |
682 finally: | 680 finally: |
683 logging.info('quitting') | 681 logging.info('quitting') |
OLD | NEW |