| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """"Serves as a client for selected APIs in Buildbucket.""" | 5 """"Serves as a client for selected APIs in Buildbucket.""" |
| 6 | 6 |
| 7 import collections | 7 import collections |
| 8 import json | 8 import json |
| 9 import logging | 9 import logging |
| 10 | 10 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 70 |
| 71 This corresponds to the Build in Buildbucket. | 71 This corresponds to the Build in Buildbucket. |
| 72 """ | 72 """ |
| 73 | 73 |
| 74 # Build statuses. | 74 # Build statuses. |
| 75 SCHEDULED = 'SCHEDULED' | 75 SCHEDULED = 'SCHEDULED' |
| 76 STARTED = 'STARTED' | 76 STARTED = 'STARTED' |
| 77 COMPLETED = 'COMPLETED' | 77 COMPLETED = 'COMPLETED' |
| 78 | 78 |
| 79 def __init__(self, raw_json_data): | 79 def __init__(self, raw_json_data): |
| 80 self.response = raw_json_data |
| 80 self.id = raw_json_data.get('id') | 81 self.id = raw_json_data.get('id') |
| 81 self.url = raw_json_data.get('url') | 82 self.url = raw_json_data.get('url') |
| 82 self.status = raw_json_data.get('status') | 83 self.status = raw_json_data.get('status') |
| 83 self.request_time = raw_json_data.get('created_ts') | 84 self.request_time = raw_json_data.get('created_ts') |
| 84 self.updated_time = raw_json_data.get('updated_ts') | 85 self.updated_time = raw_json_data.get('updated_ts') |
| 85 self.end_time = raw_json_data.get('completed_ts') | 86 self.end_time = raw_json_data.get('completed_ts') |
| 86 result_details_json = json.loads( | 87 result_details_json = json.loads( |
| 87 raw_json_data.get('result_details_json', '{}')) or {} | 88 raw_json_data.get('result_details_json', '{}')) or {} |
| 88 self.report = result_details_json.get('properties', {}).get('report', {}) | 89 self.report = result_details_json.get('properties', {}).get('report', {}) |
| 89 | 90 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 else: | 184 else: |
| 184 error_content = { | 185 error_content = { |
| 185 'error': { | 186 'error': { |
| 186 'reason': status_code, | 187 'reason': status_code, |
| 187 'message': content | 188 'message': content |
| 188 } | 189 } |
| 189 } | 190 } |
| 190 json_results.append(error_content) | 191 json_results.append(error_content) |
| 191 | 192 |
| 192 return _ConvertFuturesToResults(json_results) | 193 return _ConvertFuturesToResults(json_results) |
| OLD | NEW |