Chromium Code Reviews| Index: appengine/swarming/swarming_bot/bot_code/task_runner.py |
| diff --git a/appengine/swarming/swarming_bot/bot_code/task_runner.py b/appengine/swarming/swarming_bot/bot_code/task_runner.py |
| index 2658766d13e6ffe54224f3a17874cc473d0d27a8..f8a4004c49acdd152c0cb977a3ff1dfe3fbf1bdb 100644 |
| --- a/appengine/swarming/swarming_bot/bot_code/task_runner.py |
| +++ b/appengine/swarming/swarming_bot/bot_code/task_runner.py |
| @@ -23,6 +23,7 @@ import signal |
| import sys |
| import time |
| +from utils import file_path |
| from utils import net |
| from utils import on_error |
| from utils import subprocess42 |
| @@ -81,7 +82,8 @@ def get_run_isolated(): |
| def get_isolated_cmd( |
| - work_dir, task_details, isolated_result, min_free_space, bot_file): |
| + work_dir, task_details, isolated_result, bot_file, package_list, |
| + min_free_space): |
| """Returns the command to call run_isolated. Mocked in tests.""" |
| assert (bool(task_details.command) != |
| bool(task_details.isolated and task_details.isolated.get('input'))) |
| @@ -104,16 +106,22 @@ def get_isolated_cmd( |
| ]) |
| if task_details.cipd_input and task_details.cipd_input.get('packages'): |
| - to_pkg = lambda p: '%s:%s' % (p['package_name'], p['version']) |
| + package_json = { |
| + # Package JSON object format matches. |
|
M-A Ruel
2016/06/15 17:28:27
Can't parse this sentence
nodir
2016/06/15 17:53:42
Done.
|
| + 'packages': task_details.cipd_input['packages'], |
| + } |
| + with open(package_list, 'w') as f: |
|
M-A Ruel
2016/06/15 17:28:27
'wb'
nodir
2016/06/15 17:53:42
Done.
|
| + json.dump(package_json, f) |
| cmd.extend( |
| [ |
| '--cipd-cache', os.path.join(bot_dir, 'cipd_cache'), |
| '--cipd-client-package', |
| - to_pkg(task_details.cipd_input.get('client_package')), |
| + task_details.cipd_input['client_package']['package_name'], |
| + '--cipd-client-version', |
| + task_details.cipd_input['client_package']['version'], |
| + '--cipd-package-list', package_list, |
| '--cipd-server', task_details.cipd_input.get('server'), |
| ]) |
| - for p in task_details.cipd_input['packages']: |
| - cmd.extend(['--cipd-package', to_pkg(p)]) |
| cmd.extend( |
| [ |
| @@ -369,8 +377,10 @@ def run_command( |
| post_update(swarming_server, headers_cb(), params, None, '', 0) |
| isolated_result = os.path.join(work_dir, 'isolated_result.json') |
| + package_list = os.path.join(work_dir, 'package_list.json') |
| cmd = get_isolated_cmd( |
| - work_dir, task_details, isolated_result, min_free_space, bot_file) |
| + work_dir, task_details, isolated_result, bot_file, package_list, |
| + min_free_space) |
| # Hard timeout enforcement is deferred to run_isolated. Grace is doubled to |
| # give one 'grace_period' slot to the child process and one slot to upload |
| # the results back. |
| @@ -564,10 +574,8 @@ def run_command( |
| u'version': OUT_VERSION, |
| } |
| finally: |
| - try: |
| - os.remove(isolated_result) |
| - except OSError: |
| - pass |
| + file_path.try_remove(unicode(isolated_result)) |
| + file_path.try_remove(unicode(package_list)) |
| stop_headers_reader() |