| OLD | NEW |
| 1 # Copyright 2015 The LUCI Authors. All rights reserved. | 1 # Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed by the Apache v2.0 license that can be | 2 # Use of this source code is governed by the Apache v2.0 license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Internal bot API handlers.""" | 5 """Internal bot API handlers.""" |
| 6 | 6 |
| 7 import base64 | 7 import base64 |
| 8 import json | 8 import json |
| 9 import logging | 9 import logging |
| 10 import re | 10 import re |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 'simultaneously\nbot_overhead: %s\nisolated_stats: %s' % | 517 'simultaneously\nbot_overhead: %s\nisolated_stats: %s' % |
| 518 (bot_overhead, isolated_stats)) | 518 (bot_overhead, isolated_stats)) |
| 519 | 519 |
| 520 run_result_key = task_pack.unpack_run_result_key(task_id) | 520 run_result_key = task_pack.unpack_run_result_key(task_id) |
| 521 performance_stats = None | 521 performance_stats = None |
| 522 if isolated_stats: | 522 if isolated_stats: |
| 523 download = isolated_stats['download'] | 523 download = isolated_stats['download'] |
| 524 upload = isolated_stats['upload'] | 524 upload = isolated_stats['upload'] |
| 525 performance_stats = task_result.PerformanceStats( | 525 performance_stats = task_result.PerformanceStats( |
| 526 bot_overhead=bot_overhead, | 526 bot_overhead=bot_overhead, |
| 527 isolated_download=task_result.IsolatedOperation( | 527 isolated_download=task_result.OperationStats( |
| 528 duration=download['duration'], | 528 duration=download['duration'], |
| 529 initial_number_items=download['initial_number_items'], | 529 initial_number_items=download['initial_number_items'], |
| 530 initial_size=download['initial_size'], | 530 initial_size=download['initial_size'], |
| 531 items_cold=base64.b64decode(download['items_cold']), | 531 items_cold=base64.b64decode(download['items_cold']), |
| 532 items_hot=base64.b64decode(download['items_hot'])), | 532 items_hot=base64.b64decode(download['items_hot'])), |
| 533 isolated_upload=task_result.IsolatedOperation( | 533 isolated_upload=task_result.OperationStats( |
| 534 duration=upload['duration'], | 534 duration=upload['duration'], |
| 535 items_cold=base64.b64decode(upload['items_cold']), | 535 items_cold=base64.b64decode(upload['items_cold']), |
| 536 items_hot=base64.b64decode(upload['items_hot']))) | 536 items_hot=base64.b64decode(upload['items_hot']))) |
| 537 | 537 |
| 538 if output is not None: | 538 if output is not None: |
| 539 try: | 539 try: |
| 540 output = base64.b64decode(output) | 540 output = base64.b64decode(output) |
| 541 except UnicodeEncodeError as e: | 541 except UnicodeEncodeError as e: |
| 542 logging.error('Failed to decode output\n%s\n%r', e, output) | 542 logging.error('Failed to decode output\n%s\n%r', e, output) |
| 543 output = output.encode('ascii', 'replace') | 543 output = output.encode('ascii', 'replace') |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 ('/swarming/api/v1/bot/poll', BotPollHandler), | 667 ('/swarming/api/v1/bot/poll', BotPollHandler), |
| 668 ('/swarming/api/v1/bot/server_ping', ServerPingHandler), | 668 ('/swarming/api/v1/bot/server_ping', ServerPingHandler), |
| 669 ('/swarming/api/v1/bot/task_update', BotTaskUpdateHandler), | 669 ('/swarming/api/v1/bot/task_update', BotTaskUpdateHandler), |
| 670 ('/swarming/api/v1/bot/task_update/<task_id:[a-f0-9]+>', | 670 ('/swarming/api/v1/bot/task_update/<task_id:[a-f0-9]+>', |
| 671 BotTaskUpdateHandler), | 671 BotTaskUpdateHandler), |
| 672 ('/swarming/api/v1/bot/task_error', BotTaskErrorHandler), | 672 ('/swarming/api/v1/bot/task_error', BotTaskErrorHandler), |
| 673 ('/swarming/api/v1/bot/task_error/<task_id:[a-f0-9]+>', | 673 ('/swarming/api/v1/bot/task_error/<task_id:[a-f0-9]+>', |
| 674 BotTaskErrorHandler), | 674 BotTaskErrorHandler), |
| 675 ] | 675 ] |
| 676 return [webapp2.Route(*i) for i in routes] | 676 return [webapp2.Route(*i) for i in routes] |
| OLD | NEW |